<ItemsControl ItemsSource="{Binding NavModel.NavCommands, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" Grid.Column="0" Grid.Row="1"
ScrollViewer.HorizontalScrollBarVisibility="Disabled" HorizontalContentAlignment="Stretch">
<ItemsControl.ItemTemplate>
<DataTemplate>
<TextBlock Height="20" Margin="10,10,0,0" TextWrapping="Wrap">
<Hyperlink Command="{Binding Command}">
<Run Text="really really raelly long string"></Run>
</Hyperlink>
</TextBlock>
</DataTemplate>
</ItemsControl>
网格的宽度和高度由各种*值定义。
<Grid.ColumnDefinitions>
<ColumnDefinition Width="12*"/>
<ColumnDefinition Width="3*"/>
<ColumnDefinition Width="77*"/>
<ColumnDefinition Width="3*"/>
<ColumnDefinition Width="5*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="1*"/>
<RowDefinition Height="92*"/>
<RowDefinition Height="1*"/>
<RowDefinition Height="6*"/>
</Grid.RowDefinitions>
我试过这个没有ScrollViewer.HorizontalScrollBarVisibility =“已禁用”HorizontalContentAlignment =“Stretch”。
我如何达到理想的效果?
答案 0 :(得分:4)
我觉得有点愚蠢。解决方案是删除文本块上的Height属性:(
<TextBlock Height="20" Margin="10,10,0,0" TextWrapping="Wrap">
应该只是
<TextBlock Margin="10,10,0,0" TextWrapping="Wrap">
它有效。
答案 1 :(得分:0)
<TextBlock>
<Hyperlink NavigateUri="http://www.microsoft.com" RequestNavigate="Hyperlink_RequestNavigate">
<TextBlock TextWrapping="Wrap">
Navigate To Microsoft Navigate To Microsoft Navigate To MicrosoftNavigate To MicrosoftNavigate To Microsoft
</TextBlock>
</Hyperlink>
</TextBlock>