【发布时间】:2016-05-13 08:15:47
【问题描述】:
我在另一个 ItemsControl 中有一个 ItemsControl。此 ItemsControl 包含已售商品的列表。
我想显示那些以低于成本(负利润)销售的商品。 但我在折叠项目(行)时遇到问题。
<ItemsControl>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid>
...
...
...
<ItemsControl ItemsSource="{Binding SoldItems}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid> <!--If I hide the grid, it will create empty space.-->
...
...
...
<TextBlock Text="{Binding Profit}"></TextBlock>
</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
如果我试图隐藏网格,它会显示空行。它看起来很奇怪,因为那里有空白。
<Grid Visibility="{Binding Profit, Mode=OneWay, Converter={StaticResource ProfitVisibilityConverter}}">
知道如何隐藏整行吗?
谢谢
【问题讨论】:
-
你能用 Listbox 代替 ItemsControl。恐怕使用 itemscontrol 除了删除不需要的项目之外,您别无选择。如果您可以使用 ListBox,我可以为您提供解决方案
-
是的,我可以使用列表框...你能帮帮我吗? :)
-
其实你可以使用 ItemsControl。我找到了其他解决方案。好的,我会发布答案。
-
嘿,只是想检查是否有其他人找到比接受的答案更好的方法
标签: win-universal-app itemscontrol windows-10-universal listbox-control