In UserControl xaml, set itemsource binding as:
ItemSource ="{Binding MyList}"
MyList is loaded in ViewModel by Ria Service. VM has Loaded event. In UserControl code-behind, hook up Loaded event as:
void vm_Loaded(object sender, EventArgs e) { this.MyXamGRidd.Rows[0].IsSelected = true; }
The purpose of above code is auto selecte the first row when data is loading.
Run the application, I got error for code this.MyXamGRidd.Rows[0].IsSelected = true;. It said null object because this.MyXamGRidd.Rowsis null. but when dubug the app for this line of code. Data did loaded at this time.
How to resolve this problem?
Hi,
You can try to wrap this code in a Dispatcher call like that:
this.Dispatcher.BeginInvoke(() => { this.XGrid.Rows[0].IsSelected = true; });
Hope this helps
Hello,
Were you able to resolve your issue?
Valerie