Curios as to why this doesn't work...
-
I have a WPF application which contains a ListView defined to show the values for an item in a chart. One of the fields, State, is supposed to change as the charted values cross warning and alarm barriers. I built up the list (which was really only one item) as follows:
ObservableCollection<LegendValues> itemList = new ObservableCollection<LegendValues>(); LegendValues item = new LegenValues(); ... define the initial values ... itemList.Add( item ); myListView.ItemsSource = itemList; // further on in my code item.State = "Warn";
I also have the binding set in XAML as TwoWay. When I change the state in the item object, it does not change in the ListView. Is there something I'm missing? Thanks, Michael
-
I have a WPF application which contains a ListView defined to show the values for an item in a chart. One of the fields, State, is supposed to change as the charted values cross warning and alarm barriers. I built up the list (which was really only one item) as follows:
ObservableCollection<LegendValues> itemList = new ObservableCollection<LegendValues>(); LegendValues item = new LegenValues(); ... define the initial values ... itemList.Add( item ); myListView.ItemsSource = itemList; // further on in my code item.State = "Warn";
I also have the binding set in XAML as TwoWay. When I change the state in the item object, it does not change in the ListView. Is there something I'm missing? Thanks, Michael
-
Well...according to the documentation all I need are two things. TwoWay link on the binding between the ItemSource object and the ListIndex, and the ObservableCollection. But I can add INotifyProperty and see if that helps.
-
Well...according to the documentation all I need are two things. TwoWay link on the binding between the ItemSource object and the ListIndex, and the ObservableCollection. But I can add INotifyProperty and see if that helps.
ObservableCollection
is only used to tell the binding engine when records have been added or removed from the collection. In order to watch changes to particular properties, you need to useINotifyPropertyChanged
and raise thePropertyChanged
event."WPF has many lovers. It's a veritable porn star!" - Josh Smith
As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
-
Well...according to the documentation all I need are two things. TwoWay link on the binding between the ItemSource object and the ListIndex, and the ObservableCollection. But I can add INotifyProperty and see if that helps.
-
I have a WPF application which contains a ListView defined to show the values for an item in a chart. One of the fields, State, is supposed to change as the charted values cross warning and alarm barriers. I built up the list (which was really only one item) as follows:
ObservableCollection<LegendValues> itemList = new ObservableCollection<LegendValues>(); LegendValues item = new LegenValues(); ... define the initial values ... itemList.Add( item ); myListView.ItemsSource = itemList; // further on in my code item.State = "Warn";
I also have the binding set in XAML as TwoWay. When I change the state in the item object, it does not change in the ListView. Is there something I'm missing? Thanks, Michael