我无法在FontSize
中设置Text
的{{1}},因为TextBlock
位于TextBox
。为什么呢?
Viewbox
我可以设置所有<Grid Margin="35,30,35,0" ShowGridLines="False" >
<Grid.ColumnDefinitions>
<ColumnDefinition MinWidth="270 px" Width="2*"/>
<ColumnDefinition Width="5*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<Border Grid.Row="0" Grid.Column="0" BorderBrush="Black" BorderThickness="1,1,1,0" />
<Viewbox>
<TextBlock Margin="10,5,0,5" Grid.Row="0" Grid.Column="0">Team:</TextBlock>
</Viewbox>
<Border Grid.Row="1" Grid.Column="0" BorderBrush="Black" BorderThickness="1,1,1,0" />
<TextBlock Margin="10,5,0,5" Grid.Row="1" Grid.Column="0">Beschreibung:</TextBlock>
<Border Grid.Row="2" Grid.Column="0" BorderBrush="Black" BorderThickness="1,1,1,0" />
<TextBlock Margin="10,5,0,5" Grid.Row="2" Grid.Column="0">Milestone:</TextBlock>
<Border Grid.Row="3" Grid.Column="0" BorderBrush="Black" BorderThickness="1,1,1,1" />
<TextBlock Margin="10,5,0,5" Grid.Row="3" Grid.Column="0">Status:</TextBlock>
<Border Grid.Row="0" Grid.Column="1" BorderBrush="Black" BorderThickness="0,1,1,0" />
<TextBlock x:Name="tb_Team_dyn" Margin="10,5,0,5" Grid.Row="0" Grid.Column="1"
FontWeight="Bold" Text="{Binding Data.Team}" TextWrapping="Wrap"></TextBlock>
<Border Grid.Row="1" Grid.Column="1" BorderBrush="Black" BorderThickness="0,1,1,0" />
<TextBlock x:Name="tb_Descr_dyn" Margin="10,5,0,5" Grid.Row="1" Grid.Column="1"
FontWeight="Bold" Text="{Binding Data.Description}" TextWrapping="Wrap"/>
<Border Grid.Row="2" Grid.Column="1" BorderBrush="Black" BorderThickness="0,1,1,0" />
<TextBlock x:Name="tb_Milestone_dyn" Margin="10,5,0,5" Grid.Row="2" Grid.Column="1"
FontWeight="Bold" Text="{Binding Data.Milestone}" TextWrapping="Wrap"/>
<Border Grid.Row="3" Grid.Column="1" BorderBrush="Black" BorderThickness="0,1,1,1" />
<StackPanel Margin="10,5,0,5" Grid.Row="3" Grid.Column="1" Orientation="Horizontal">
<Image x:Name="imgSmile" MaxWidth="38" Source="{Binding Data.Smiley}" />
<TextBlock x:Name="tb_Status_dyn" Margin="{Binding Data.SmileyMargin}"
Foreground="{Binding Data.Col}" FontWeight="Bold"
Text="{Binding Data.Status}" TextWrapping="Wrap"></TextBlock>
</StackPanel>
</Grid>
的{{1}},但不能设置FontSize
中TextBlock
的{{1}}。
答案 0 :(得分:2)
请记住,FontSize设置文本的实际大小,但Viewbox会在文本布局和呈现后对其进行缩放。如果在视图框中放置具有固定宽度和高度的元素,您将看到相同的效果。 Viewbox不会更改Width,Height或FontSize属性本身,但最终渲染显示不同。
您实际需要的是Viewbox本身的初始布局,使其初始大小等于TextBlock的初始大小,这将有效地将Viewbox的缩放比例设置为1:1。您可以通过多种方式实现此目的,具体取决于您的应用程序(直接在代码中,使用ValueConverters绑定等),但基本方法是测量父元素的初始大小,并设置适当的边距以缩小Viewbox中的Viewbox。分配给它的布局区域。然后,这将允许Viewbox在保持您设置的边距时随其父级一起更改大小。另请查看Viewbox上的StretchDirection,MinHeight和MinWidth。
答案 1 :(得分:1)
一些示例代码会有所帮助。脱离我的脑海......文本框是否设置为多行?如果不是,内部文本可能会随文本框一起延伸。