Mahapps Metro Datagrid - CPU使用率高&分组性能极差

时间:2014-05-24 19:55:21

标签: wpf performance datagrid cpu-usage mahapps.metro

我有一个简单的mahapps metro数据网格,有6列。我在数据网格中填充了大约500行数据,并尝试按列标题进行分组。在分组工作的情况下,计算机CPU的使用率高达99%,除了关闭应用程序之外我无法做其他事情。

以下是用于数据网格的分组模板。我不确定它是扩展器控件还是数据网格本身是错误的?任何想法?

我应该指定cpu使用率只有在我尝试扩展datagrid中的组时才会上升(Grpahic渲染问题?)。默认情况下我让他们崩溃了。如果没有应用于数据网格或列的额外样式或teplates,也会发生这种情况。

 <DataGrid.GroupStyle>
    <!-- Style for groups at top level. -->
    <GroupStyle>
      <GroupStyle.ContainerStyle>
        <Style TargetType="{x:Type GroupItem}">
          <Setter Property="Template">
            <Setter.Value>
              <ControlTemplate>
                <Expander IsExpanded="false">
                  <Expander.Header>
                    <StackPanel Orientation="Horizontal">
                      <TextBlock VerticalAlignment="Bottom" FontSize="13" FontWeight="Bold" Foreground="Ghostwhite" Text="{Binding Name}" />
                      <TextBlock Margin="10,0,0,0" VerticalAlignment="Bottom" FontSize="13" FontStyle="Italic" FontWeight="Bold" Foreground="Green" Text="{Binding ItemCount}" />
                    </StackPanel>
                  </Expander.Header>
                  <ItemsPresenter />
                </Expander>
              </ControlTemplate>
            </Setter.Value>
          </Setter>
        </Style>
      </GroupStyle.ContainerStyle>
    </GroupStyle>
  </DataGrid.GroupStyle>

0 个答案:

没有答案
相关问题