GridView在wpf中占用太多CPU

时间:2012-08-09 16:04:34

标签: c# wpf performance gridview componentart

我在我的wpf应用程序中有这个GridView定义,我也在使用ComponentArt

<my1:GridView Name="gridView1" Theme="ArcticWhite" Indent="40" RowClicked="gridView1_RowClicked_1" AllowColumnFreezing="False" AllowRowFreezing="False" ColumnResizingMode="Normal" AllowColumnReordering="False" AutoGenerateColumns="False" IsHitTestVisible="True" ThemeVariant="Standard" Foreground="#FFDBDBCD">
    <my1:GridView.Columns>
        <my1:GridViewTemplateColumn Binding="{Binding}"  Header="Local">
            <my1:GridViewTemplateColumn.CellTemplate>
                <DataTemplate>
                    <Grid Margin="-7,-3,-2,-3" Name="grid1">
                        <Grid.Background>
                            <MultiBinding Converter="{StaticResource BackgroundBrushConverter}">
                                <Binding ElementName="r1" Path="Fill"></Binding>
                                <Binding ElementName="cbColores" Path="IsChecked"></Binding>
                            </MultiBinding>
                        </Grid.Background>
                        <Rectangle Name="r1" Fill="{Binding Converter={StaticResource BrushConverter}}" Width="1" Height="1"></Rectangle>
                        <TextBlock Margin="3" Foreground="Black" Text="{Binding Local}" FontFamily="Calibri" FontWeight="Bold" FontSize="13">
                    <TextBlock.Effect>
                        <DropShadowEffect Color="White" BlurRadius="3" ShadowDepth="0" Opacity="5" />
                    </TextBlock.Effect>
                        </TextBlock>
                    </Grid>
                </DataTemplate>
            </my1:GridViewTemplateColumn.CellTemplate>
        </my1:GridViewTemplateColumn>
        <my1:GridViewTemplateColumn Binding="{Binding}"  Header="Linea">
            <my1:GridViewTemplateColumn.CellTemplate>
                <DataTemplate>
                    <Grid  Margin="-7,-3,-2,-3" Name="grid2">
                        <Grid.Background>
                            <MultiBinding Converter="{StaticResource BackgroundBrushConverter}">
                                <Binding ElementName="r2" Path="Fill"></Binding>
                                <Binding ElementName="cbColores" Path="IsChecked"></Binding>
                            </MultiBinding>
                        </Grid.Background>
                        <Rectangle Name="r2" Fill="{Binding Converter={StaticResource BrushConverter}}" Width="1" Height="1"></Rectangle>
                        <TextBlock Margin="3" Foreground="Black" Text="{Binding Linea}"  FontFamily="Calibri" FontWeight="Bold" FontSize="13">
                    <TextBlock.Effect>
                        <DropShadowEffect Color="White" BlurRadius="3" ShadowDepth="0" Opacity="5" />
                    </TextBlock.Effect>
                        </TextBlock>
                    </Grid>
                </DataTemplate>
            </my1:GridViewTemplateColumn.CellTemplate>
        </my1:GridViewTemplateColumn>
    </my1:GridView.Columns>
</my1:GridView>

当我打开应用程序时,cpu增加到50-60%,没有做任何事情;并保持该速率,直到我关闭应用程序

我能做些什么来改善表现吗?

提前致谢

1 个答案:

答案 0 :(得分:0)

您可以尝试从单元格模板中删除DropShadowEffect - 特别是如果此网格中有大量单元格并且未启用虚拟化。据我了解,您应该尽量避免同时在许多目标上使用DropShadowEffectBlurEffect