Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# GridView在wpf中占用太多CPU_C#_Wpf_Performance_Gridview_Componentart - Fatal编程技术网

C# GridView在wpf中占用太多CPU

C# GridView在wpf中占用太多CPU,c#,wpf,performance,gridview,componentart,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

我在我的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%,而不做任何事情;一直保持这个速度直到我关闭应用程序

我能做些什么来提高性能吗


提前感谢

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

此外,如果有多行,请尝试启用虚拟化stackpanel。如果您需要dropshadow效果,则在底部有轻微渲染偏移的地方,在每个文本块的顶部使用两个文本块更有效。