没有为文本设置字体大小

时间:2015-05-07 15:14:54

标签: c# .net wpf wcf

以下是聊天窗口。字体大小没有设置在哪里放这个?对于聊天文本,我们有发送按钮的字体大小     

    MinHeight="550" MinWidth="834"
            Closed="Window_Closed" >
        <Window.Resources>
            <Style x:Key="SpeechOptionsStyle" TargetType="RadioButton">
                <Setter Property="Margin" Value="2,8,0,0" />
            </Style>
            <Style x:Key="ChatButtonStyle" TargetType="Button">
                <Setter Property="Background" Value="Transparent" />
                <Setter Property="Height" Value="23" />
                <Setter Property="VerticalAlignment" Value="Top" />
                <Setter Property="HorizontalAlignment" Value="Right" />
                <Setter Property="Width" Value="150" />
                <Setter Property="Margin" Value="0,5,0,0" />
            </Style>
        </Window.Resources>

        <Grid>
            <Grid.Background>
                <LinearGradientBrush>
                    <GradientStop Color="LightSlateGray" Offset="0"/>
                    <GradientStop Color="Gainsboro" Offset="0.7"/>
                    <GradientStop Color="LightSlateGray" Offset="0.95"/>
                </LinearGradientBrush>
            </Grid.Background>

            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="*" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="170" />
            </Grid.ColumnDefinitions>

            <ListBox Grid.Row="1" Grid.Column="0" x:Name="chatListBoxMsgs" Margin="10" 

    HorizontalContentAlignment="Stretch" >
                <ListBox.ItemContainerStyle>
                    <Style TargetType="{x:Type ListBoxItem}" >
                        <EventSetter Event="MouseDoubleClick" 

    Handler="chatListBoxMsgs_MouseDoubleClick" />
                    </Style>
                </ListBox.ItemContainerStyle>
            </ListBox>

            <Grid Grid.Row="1" Grid.Column="1" HorizontalAlignment="Right" Margin="10" 

    Width="150">
                <Grid.RowDefinitions>
                    <RowDefinition Height="*" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>

                <ListBox Grid.Row="0" x:Name="chatListBoxNames" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="150"  />

                <StackPanel Grid.Row="1" Margin="0,10,0,0">   <CheckBox Visibility="Hidden"  x:Name="chatCheckBoxWhisper" Height="17" HorizontalAlignment="Left" Foreground="Black" FontSize="12" >Whisper Mode</CheckBox>

                </StackPanel>

            </Grid>

            <TextBlock Visibility="Visible" Grid.Row="2" Grid.Column="0" x:Name="chatLabelWritingMsg" 

    Height="45" VerticalAlignment="Top" Foreground="MediumBlue" 
                       TextWrapping="Wrap" Margin="10,0,0,0">Status</TextBlock>

            <StackPanel Grid.Row="2" Grid.Column="1" Grid.RowSpan="2" 

    Orientation="Vertical" Margin="10,0" >
                <Button x:Name="chatButtonConnect"  Click="chatButtonConnect_Click" 

    Style="{StaticResource ChatButtonStyle}" >Connect</Button>
                <Button x:Name="chatButtonDisconnect"  Click="chatButtonDisconnect_Click" 

    Style="{StaticResource ChatButtonStyle}" >Disconnect</Button>
            </StackPanel>

            <Grid Grid.Row="3" Grid.Column="0">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="Auto" />
                </Grid.ColumnDefinitions>

                <TextBox Grid.Column="0" x:Name="chatTxtBoxType" Height="60" 

    VerticalAlignment="Top" Margin="10,0,5,5" TextWrapping="Wrap" 

    SpellCheck.IsEnabled="True" />
                <Button Grid.Column="1" x:Name="chatButtonSend" 

    Click="chatButtonSend_Click" Height="60" VerticalAlignment="Top" 
                        HorizontalAlignment="Right" Width="50" Margin="5,0,5,5" 

    FontSize="14">Send</Button>
            </Grid>
        </Grid>
    </Window>

我们这里有发送按钮的fontsize,我们将字体ssize放在默认为8的聊天文本中

1 个答案:

答案 0 :(得分:0)

从您的代码中我想您要设置chatTxtBoxType的字体大小。你可以在那里做(使用14的示例大小):

<TextBox Grid.Column="0" x:Name="chatTxtBoxType" Height="60" 
 VerticalAlignment="Top" Margin="10,0,5,5" TextWrapping="Wrap" 
 SpellCheck.IsEnabled="True" FontSize="14"/>

或者使用样式,就像你对按钮所做的那样(在这种情况下,你可能想要将其他一些属性移动到样式中):

<Window.Resources>
  <Style x:Key="ChatBoxStyle" TargetType="TextBox">
    <Setter Property="FontSize" Value="14" />
  </Style>
  ...

<TextBox Grid.Column="0" x:Name="chatTxtBoxType" Height="60" 
 VerticalAlignment="Top" Margin="10,0,5,5" TextWrapping="Wrap" 
 SpellCheck.IsEnabled="True" Style="{StaticResource ChatBoxStyle}"/>