2010-10-01 17 views
2

我正在將數據分組到WPF DataGrid中。這需要很長時間,所以我想顯示一個加載欄/裝飾。鉤入集合填充的時刻,然後移除裝載裝飾器?

我正在使用MVVM。當數據網格完成分組時,你將如何移除/淡出加載條/裝飾條。

如何獲得數據分組爲100%的時刻?這可以以某種方式設置在XAML或檢索等?

回答

0

我認爲你可以使用ItemContainerGenerator.StatusChanged事件。當狀態變爲ContainersGenerated時,分組完成。

請注意,這只是一個假設,但我懷疑,當你改變GroupDescriptions的容器再生...

+0

我在這裏找到了一個很好的例子:http://www.get-the-solution.net/index-1-14-69-IsAsync---Meldung-%26u.html – Elisabeth 2010-10-01 18:23:41

+0

有趣,但我'米不知道它與分組有什麼關係... – 2010-10-01 18:35:21

+0

啊是的,我不能再編輯評論...我仍然想說,我可能垃圾分組; ;-) – Elisabeth 2010-10-01 18:59:25

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%。至少我可以直觀地認出它。 :)