我创建了univeral windows app。我使用GridView和ItemsWrapGrid。我需要横向拉伸项目。
这是我的测试代码:
<GridView x:Name="Test"
AutomationProperties.AutomationId="ItemGridView"
AutomationProperties.Name="Items In Group"
IsItemClickEnabled="True"
IsSwipeEnabled="False"
ScrollViewer.VerticalScrollBarVisibility="Hidden"
ScrollViewer.VerticalScrollMode="Disabled"
SelectionMode="Single">
<GridView.ItemContainerStyle>
<Style TargetType="GridViewItem">
<Setter Property="HorizontalAlignment" Value="Stretch" />
<Setter Property="VerticalAlignment" Value="Stretch" />
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
<Setter Property="VerticalContentAlignment" Value="Stretch" />
</Style>
</GridView.ItemContainerStyle>
<GridView.ItemTemplate>
<DataTemplate>
<TextBlock MinWidth="100"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
Text="{Binding}"
TextWrapping="WrapWholeWords" />
</DataTemplate>
</GridView.ItemTemplate>
<GridView.Transitions>
<TransitionCollection>
<EntranceThemeTransition />
</TransitionCollection>
</GridView.Transitions>
<GridView.ItemsPanel>
<ItemsPanelTemplate>
<ItemsWrapGrid Orientation="Vertical" />
</ItemsPanelTemplate>
</GridView.ItemsPanel>
</GridView>
这是我的代码:
this.InitializeComponent();
var items = new List<string>
{
"test",
"test test",
"test test 000 1111 test test 000 1111",
};
Test.ItemsSource = items;
这是我的结果:
最后一行的文字并非全部。如何显示全文?
答案 0 :(得分:2)
尝试使用ItemsStackPanel
代替ItemsWrapGrid
。
<GridView.ItemsPanel>
<ItemsPanelTemplate>
<ItemsStackPanel Orientation="Vertical" />
</ItemsPanelTemplate>
</GridView.ItemsPanel>