ViewBox字体对最小分辨率不易读

时间:2016-09-01 16:15:54

标签: c# wpf

我正在使用ViewBox来显示水平方向的标签列表并保持易读性,当我将窗口缩小到我设置的最小分辨率时,问题是:800我得到这个结果:

enter image description here

你怎么看我无法阅读的内容。这种情况只发生在窗口达到最小分辨率时,当ViewBox处于最佳分辨率时工作得非常好:

enter image description here

我不知道我做错了什么。我从未使用ViewBox,这是我的代码:

<Viewbox TextOptions.TextFormattingMode="Display" Stretch="Uniform" Grid.Row="1" Grid.Column="1" Grid.RowSpan="1">
    <StackPanel>
        <Grid Margin="0, 1, 0, 0">
            <Label Content="Foo" FontWeight="Bold"/>
            <Label Content="{Binding Path = EventLeague}" HorizontalAlignment="Center"/>
        </Grid>
        <Grid Margin="0,-10, 0, 0">
            <Label Content="Date" FontWeight="Bold"/>
            <Label Content="{Binding Path = EventDate}" HorizontalAlignment="Center"/>
        </Grid>
        <Grid Margin="0,-10, 0, 0">
            <Label Content="Week" FontWeight="Bold"/>
            <Label Content="{Binding Path = EventGameWeek}" HorizontalAlignment="Center"/>
         </Grid>
         <Grid Margin="0,-10, 0, 0">
             <Label Content="Home" FontWeight="Bold"/>
             <Label Content="{Binding Path = EventStart}" HorizontalAlignment="Center"/>
         </Grid>
         <Grid Margin="0,-10, 0, 0">
             <Label Content="Away" FontWeight="Bold"/>
             <Label Content="{Binding Path = EventStadium}" HorizontalAlignment="Center"/>
         </Grid>
     </StackPanel>  
  </Viewbox>

1 个答案:

答案 0 :(得分:1)

您的网格没有行或列这意味着所有内容都会进入网格单元格0,0

试试这个

<Viewbox TextOptions.TextFormattingMode="Display" Stretch="Uniform" Grid.Row="1" Grid.Column="1" Grid.RowSpan="1" MinHeight="500"  MinWidth="500" >
        <UniformGrid Columns="2">
            <Label Content="Foo" FontWeight="Bold"/>
            <Label Content="{Binding Path = EventLeague}" HorizontalAlignment="Center"/>
            <Label Content="Date" FontWeight="Bold"/>
            <Label Content="{Binding Path = EventDate}" HorizontalAlignment="Center"/>
            <Label Content="Week" FontWeight="Bold"/>
            <Label Content="{Binding Path = EventGameWeek}" HorizontalAlignment="Center"/>
            <Label Content="Home" FontWeight="Bold"/>
            <Label Content="{Binding Path = EventStart}" HorizontalAlignment="Center"/>
            <Label Content="Away" FontWeight="Bold"/>
            <Label Content="{Binding Path = EventStadium}" HorizontalAlignment="Center"/>
         </UniformGrid >
  </Viewbox>

编辑:

因为你已经澄清了尺寸是你的问题而不是控件的不可读性

然后视图框的工作方式是对其内部的内容执行图像拉伸以使其适合其中,

所以如果ViewBox是100宽,但里面的项目是500宽度,那么它们缩小到原始大小的1/5,以便适合

如果您拥有Stretch="Uniform"那么它将在缩小和增长时保持宽高比,如果控件的大小太小,则设置Viewbox的MinHeightMinWidth值控制最小尺寸