0
我有這樣的GridView的定義在我的WPF應用程序,還我使用ComponentArtGridView控件需要太多的CPU在WPF
<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%,而不做任何事情;在這樣的速度保持,直到我關閉應用程序
有什麼我可以做,以提高性能?
在此先感謝
此外,如果你有很多行嘗試啓用虛擬化的StackPanel。如果你需要陰影效果,那麼在兩個文本塊之間使用兩個文本塊會更有效,其中最下面的文本塊具有輕微的渲染偏移量。 – FuleSnabel 2012-08-09 19:18:13