不想在调整窗体大小时更改字体大小

时间:2013-08-29 14:22:03

标签: c# wpf user-controls resize wpf-controls

我有一个Windows窗体和一个用户控件。 Windows窗体在网格中有4个用户控件表单。用户控件表单有Grid。这个网格有很多TextBlock。当我调整窗体大小时,这些文本块也会调整大小,文本内部的字体大小也会更改。但是我希望在Windows窗体的所有网格中修改字体大小(在Windows窗体托管的所有用户控件中,用户控件的第1个网格必须具有相同的字体大小。)当窗体大小很小时,文本可以被修剪(如果文本不适合可用空间)但在Windows窗体托管的特定用户控件表单中不应减小字体大小。

  <Grid>
    <Grid.RowDefinitions>
        <RowDefinition Height="*" />
        <RowDefinition Height="*" />
        <RowDefinition Height="*" />
        <RowDefinition Height="*" />
        <RowDefinition Height="*" />
        <RowDefinition Height="*" />
        <RowDefinition Height="*" />
        <RowDefinition Height="*" />
        <RowDefinition Height="*" />
        <RowDefinition Height="*" />
        <RowDefinition Height="*" />
        <RowDefinition Height="*" />
        <RowDefinition Height="*" />
        <RowDefinition Height="*" />
        <RowDefinition Height="*" />
        <RowDefinition Height="*" />
        <RowDefinition Height="*" />
    </Grid.RowDefinitions>
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width=".3*" />
        <ColumnDefinition Width=".7*" />
    </Grid.ColumnDefinitions>

        <TextBlock x:Name="text"
               FontSize="16"
               FontWeight="Bold"
               TextTrimming="CharacterEllipsis"
               Grid.Row="0"
               Grid.ColumnSpan="2" HorizontalAlignment="Stretch" />

这是用户控制文件的示例xaml代码.TextBlock列表一直在继续。我有第一个文本块的问题。它将从一个参数中获取文本。如果在Windows窗体中,一个usercontrol的第一个网格当时的文本很小,则fontsize很高。但是,如果其他用户控件的第一个网格具有非常大的文本,那么此时的字体大小很小。因此,在相同的窗体中存在不同的字体大小看起来很奇怪。

所以有人可以帮我这个吗?在此先感谢。

0 个答案:

没有答案
相关问题