2

我在 WPF DataGrid 中对数据进行分组。这需要很长时间,所以我想展示一个加载栏/装饰器。

我正在使用 MVVM。当数据网格完成分组时,您将如何删除/淡出加载栏/装饰器。

如何获得数据 100% 分组的时刻?这可以以某种方式在 XAML 中设置或检索等吗?

4

2 回答 2

0

一种解决方案可能是绑定到扩展器的可见性。因为只有当所有数据都被分组时,扩展器才可见。但这仅在您将 IsExpanded 设置为 TRUE 时才有效,否则扩展器立即可见,并且当您单击扩展器箭头时会发生分组。

我的扩展器在默认设置中未展开。所以我尝试通过撕掉 RowStyle 和 CellStyle 来加速扩展器的扩展。这是我可以在不破坏显示交替背景的不可编辑网格的功能的情况下实现的最小 xaml

 <Style x:Key="DataGridRowStyle" TargetType="{x:Type DataGridRow}">               
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type DataGridRow}">
                            <Border Background="{TemplateBinding Background}" SnapsToDevicePixels="True">                                                            
                               <DataGridCellsPresenter Grid.Column="1" ItemsPanel="{TemplateBinding ItemsPanel}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>   
                            </Border>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>

            <Style x:Key="DataGridCellStyle" TargetType="{x:Type DataGridCell}">
                <Setter Property="Background" Value="Transparent" />
                <Setter Property="BorderBrush" Value="Transparent" />             
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type DataGridCell}">                          
                                <ContentPresenter />                
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
                <Style.Triggers>
                    <Trigger Property="IsSelected" Value="True">                     
                        <Setter Property="Foreground" Value="Red"/>                    
                    </Trigger>
                </Style.Triggers>
            </Style>

现在扩张速度更快,我猜大约 30-40%。至少我在视觉上认出了它。:)

于 2010-10-01T19:37:12.583 回答
0

我认为您可以使用该ItemContainerGenerator.StatusChanged事件。当状态变为 时ContainersGenerated,分组完成。

请注意,这只是一个假设,但我怀疑容器会在您更改GroupDescriptions...

于 2010-10-01T18:14:27.243 回答