我尝试根据两个组合框的选择加载数据网格。选择组合框项时,它会更新SelectedAccounts属性,该属性设置为DataSrid绑定的ItemSource。我检查了ItemSource是否快速更新,但WPF DataGrid需要很长时间才能显示数据(~2500行)。请建议我提高装载性能。
<DataGrid Name="dgSelecteAccounts" Grid.Row="2" Grid.Column="2" ItemsSource="{Binding SelectedAccounts}" SelectionMode="Extended" EnableRowVirtualization="True" Margin="0,25,0,0" Grid.RowSpan="2" Width="600">
<DataGrid.Columns>
<DataGridTextColumn Header="Account Code" Binding="{Binding Code}" IsReadOnly="True" Width="100" SortDirection="Ascending" />
<DataGridTextColumn Header="Account Name" Binding="{Binding Name}" IsReadOnly="True" Width="300" />
</DataGrid.Columns>
</DataGrid>
<StackPanel Grid.Row="0" Grid.Column="0" Orientation="Horizontal" Grid.ColumnSpan="3" HorizontalAlignment="Left" Width="890" Height="28" Grid.RowSpan="3" VerticalAlignment="Top">
<Label Content="As of Date:" Foreground="Black"/>
<ComboBox Width="135" ItemsSource="{Binding AsOfDates}" SelectedItem="{Binding SelectedPeriod, Mode=TwoWay, UpdateSourceTrigger=Explicit}" util:CancellableSelectionBehavior.SelectionChangeAllowedChecker="{Binding FilterChangedCheck}"/>
<Label Content="{Binding SelectedCategory.Name}" ContentStringFormat=" {0}:" Foreground="Black" Margin="15,0,0,0" />
<ComboBox ItemsSource="{Binding AumCategoryValues}" DisplayMemberPath="Value" SelectedItem="{Binding SelectedCategoryValue, Mode=TwoWay, UpdateSourceTrigger=Explicit}" Width="135" util:CancellableSelectionBehavior.SelectionChangeAllowedChecker="{Binding FilterChangedCheck}" />
</StackPanel>
private ObservableCollection<FirmAumAccount> selectedAccounts;
public ObservableCollection<FirmAumAccount> SelectedAccounts
{
get { return selectedAccounts; }
set
{
selectedAccounts = value;
RaisePropertyChangedEvent("SelectedAccounts");
}
}