All docs
V20.1
20.1
19.2
The page you are viewing does not exist in version 19.2. This link will take you to the root page.
19.1
The page you are viewing does not exist in version 19.1. This link will take you to the root page.
18.2
The page you are viewing does not exist in version 18.2. This link will take you to the root page.
18.1
The page you are viewing does not exist in version 18.1. This link will take you to the root page.
17.2
The page you are viewing does not exist in version 17.2. This link will take you to the root page.

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

Declaration

public string KeyProperty { get; set; }
Public Property KeyProperty As String

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; }
} 
See Also