Say you have an observable collection of the type of the Foo object, and you have a custom ListView that the user selects.
Your linked data object:
// property with getter / setter / INotifyPropertyChanged ObservableCollection<Foo> MyCollection;
In XAML:
<ListView ItemsSource={Binding MyCollection} />
Is it more appropriate to link to SelectedIndex in XAML and create the following in your data object:
int SelectedIndex { get; set; } // also raising property changed notifications Foo SelectedObject { get { return MyCollection[SelectedIndex]; } }
Or create this and bind to SelectedItem in XAML:
Foo SelectedObject { get; set; }
And why?
Clark source share