Question about MVVMexperiment projectQuestion about MVVMexperiment project
Old forum URL: forums.lhotka.net/forums/t/8170.aspx
lukky posted on Tuesday, December 15, 2009
@Rocky:
In the MVVMexperiment project (CSLA 3.8.2 for Windows), you have the following piece of code in DataListViewModel.cs:
///
/// Gets or sets the SelectedItems object.
///
public static readonly DependencyProperty SelectedItemsProperty =
DependencyProperty.Register("SelectedItems"), typeof(System.Collections.ObjectModel.ObservableCollection), typeof(DataListViewModel), new PropertyMetadata(null));
///
/// Gets or sets the SelectedItems object.
///
public System.Collections.ObjectModel.ObservableCollection SelectedItems
{
get { return (System.Collections.ObjectModel.ObservableCollection)GetValue(SelectedItemsProperty); }
set { SetValue(SelectedItemsProperty, value); OnPropertyChanged("SelectedItems"); }
}
namely, you call OnpropertyChanged() after the call to SetValue(). Is there a reason for this, or is it some leftover from some experiment ?
In another file of the same project, DataViewModel.cs, you just call SetValue(), so I'm a bit puzzled.
ThanksRockfordLhotka replied on Tuesday, December 15, 2009
I think I was having trouble getting PropertyChanged to raise reliably. Theoretically DependencyObject (the base class) is supposed to raise the event, but I think it wasn't doing it for some reason...lukky replied on Tuesday, December 15, 2009
Rocky,
removing the call doesn't seem to change anything as far as I can tell.
FYI, I'm running this on Windows 7 + VS2010 beta 2 if it changes anything.
If you remember more details, please post :-)
regardsRockfordLhotka replied on Wednesday, December 16, 2009
It may well work now.
I was doing this on beta code, and trying to get SL and .NET to both work with the same code. I don't remember if the problem was on the .NET or SL side of things - but it seems to me there was some inconsistency that I was fighting with.
But if it works properly now, then that's excellent! :)
Copyright (c) Marimer LLC