【发布时间】:2016-08-01 09:19:14
【问题描述】:
ItemsControl 中的WrapGrid 将第一项的宽度作为所有子项的默认宽度。是否有任何解决方法可以根据每个项目的内容使 itemwidth 拉伸? 这是我的 XAML。
<Grid Grid.Row="2">
<ItemsControl Grid.Column="1" ItemsSource="{x:Bind articleTags}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<WrapGrid Orientation="Horizontal"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Border BorderBrush="#E1E1E1" HorizontalAlignment="Stretch" Background="#E1E1E1" Margin="4,4,0,0">
<TextBlock Text="{Binding NAME}" Margin="6,0,6,0"/>
</Border>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</Grid>
在第二张图片中,'newsletters' 项目没有完全显示,因为它占用了第一个项目的宽度。
如何解决?
【问题讨论】:
标签: xaml win-universal-app uwp itemscontrol uwp-xaml