抓住集合被填满并移除加载装饰器的那一刻?

发布于 2024-09-25 17:37:40 字数 152 浏览 3 评论 0原文

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

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

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

I am grouping data in a WPF DataGrid. that takes very long so I want to show a Loading bar/adorner.

I am using MVVM. How would you remove/fade out the loading bar/adorner when the datagrid has finished the grouping.

How do I get the moment when the Data is grouped 100%? Can this somehow be set in XAML or retrieved etc.?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

猫七 2024-10-02 17:37:40

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

请注意,这只是一个假设,但我怀疑当您更改 GroupDescriptions 时容器会重新生成...

I think you could use the ItemContainerGenerator.StatusChanged event. When the status will change to ContainersGenerated, the grouping is complete.

Note that it's just an assumption, but I suspect the containers are regenerated when you change the GroupDescriptions...

余生共白头 2024-10-02 17:37:40

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

我的 Expander 在默认设置下未展开。所以我尝试通过剥离 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%。至少我在视觉上认出了它。 :)

one solution could be to bind to the Visibilty of the Expander. Because only when all data is grouped the expander is visible. But this works only when you set the IsExpanded to TRUE, else the expander is visible immediately and the grouping happens when you click on the expander arrow.

My Expander is not expanded in default setting. So I tried to speed up the expanding of the expander by ripping the RowStyle and CellStyle. This is the minimum of xaml I could achieve without breaking my functionality of a not editable grid showing alternating BackGround

 <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>

The expanding goes faster now I guess approximately 30-40%. At least I recognize it visually. :)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文