我有一个Windows 8.1应用程序GridView绑定到自定义(可排序,重复数据删除)可观察集合.在这个集合中,我做了一些重过滤并为每个项目设置了一个IsHidden标志.
在项目的数据模板中,如果IsHidden标志设置为true,则存在使项目折叠的条件.
<Grid Width="160" Height="280" Visibility="{Binding IsHidden, Converter={StaticResource InvertedBooleanToVisibilityConverter}}">
Run Code Online (Sandbox Code Playgroud)
此方法适用于Windows Phone 8.1 XAML,使项目从该项中消失,ListView但在Windows 8.1中不起作用GridView.Windows 8.1的问题在于,当我将集合中的项目设置为隐藏时,id会从中消失,GridView但会留下一个空位,因此存在间隙GridView.

关于如何解决它的任何想法?也许相同的XAML风格编辑?
以下是重现问题的最小解决方案:https://dl.dropboxusercontent.com/u/73642/gv.zip
我尝试将项目的宽度和高度绑定到隐藏标志,并在隐藏项目时将其设置为0,但它没有帮助,仍然是一个空白GridView.
更新:一种解决方法是过滤实际的绑定集合,但由于某些业务需求,这是不可能的.
在CSS flexible框布局模块中,它说:
折叠的弹性项目完全从渲染中删除,但留下了"支柱"
这表现得像visibility: hidden吗?如果答案是肯定的,那么为什么要visibility: collapse介绍?
<DockPanel Grid.Row="1" HorizontalAlignment="Right" Width="300">
<Button x:Name="startPackageSendButton" Command="{Binding StartPackageSendingProcessCommand}" Style="{StaticResource blueButtonStyle}" Content="Start" Width="100" VerticalAlignment="Top" Margin="0,0,0,0" Visibility="Visible" HorizontalAlignment="Right"/>
<Button x:Name="clearPackageSendButton" Command="{Binding ClearPackageSendingProcessCommand}" Style="{StaticResource blueButtonStyle}" Content="Clear" Width="100" VerticalAlignment="Top" Margin="0,0,0,0" Visibility="Collapsed" HorizontalAlignment="Right"/>
<Button x:Name="cancelPackageSendButton" Command="{Binding CancelPackageSendingProcessCommand}" Style="{StaticResource blueButtonStyle}" Content="Stop" Width="100" VerticalAlignment="Top" Margin="0,0,0,0" Visibility="Visible" HorizontalAlignment="Right"/>
</DockPanel>
Run Code Online (Sandbox Code Playgroud)
我正在使用Dockpanel水平对齐堆叠一些按钮。如果某些按钮不是,Visible我在按钮之间有空格。
如果按钮未Visibility设置为可见,我如何消除空格?有什么技术可以达到这种效果吗?
编辑:我按照建议将隐藏更改为折叠。