VirtualSourceBase.KeyProperty Property
Gets or sets a name of key field. The virtual source uses this field to reload specific rows and find the selected row after refresh.
Namespace: DevExpress.Xpf.Data
Assembly: DevExpress.Xpf.Core.v20.1.dll
NuGet Packages: DevExpress.WindowsDesktop.Wpf.Core, DevExpress.Wpf.Core
Declaration
Property Value
Type | Description |
---|---|
String | A name of key field. |
Remarks
Reload Individual Rows
Use the InfiniteAsyncSource.ReloadRows / PagedAsyncSource.ReloadRows method to update individual rows.
private void Button_Click(object sender, RoutedEventArgs e) {
int[] selectedRowIds = grid.SelectedItems.Cast<IssueData>().Select(x => x.Id).ToArray();
((InfiniteAsyncSource)(grid.ItemsSource)).ReloadRows(selectedRowIds);
}
Specify the KeyProperty
property to allow a virtual source to construct a filter with an InOperator.
var source = new InfiniteAsyncSource() {
ElementType = typeof(IssueData),
KeyProperty = nameof(IssueData.Id)
};
public class IssueData {
public int Id { get; private set; }
public string Subject { get; private set; }
public string User { get; private set; }
public DateTime Created { get; private set; }
public int Votes { get; private set; }
public Priority Priority { get; private set; }
}
Retain a Selected Row and Scroll Position After Refresh
The FetchRowsEventArgsBase.Take property returns the number of rows that should be reloaded. Use this property to allow the InfiniteAsyncSource to retain a selected row and scroll position after refresh. The PagedAsyncSource retains a selected row and scroll position by default.
If data in your source are changed frequently, you can retain the same selected row after refresh. Specify the KeyProperty property to make a virtual source find the selected row by a specific field:
var source = new InfiniteAsyncSource() {
ElementType = typeof(IssueData),
KeyProperty = nameof(IssueData.Id)
};
public class IssueData {
public int Id { get; private set; }
public string Subject { get; private set; }
public string User { get; private set; }
public DateTime Created { get; private set; }
public int Votes { get; private set; }
public Priority Priority { get; private set; }
}