MVVMLight blocking UI Updates?

Jun 22, 2011 at 8:02 PM
Edited Jun 22, 2011 at 8:03 PM

Hi I am writing my second windows 7 phone app. With this one I am trying MVVMLight.

I have a ViewModel that communicates to a Model via a instance (property) of the model.  In the Model, I have an ObservableCollection<TimeSlotTemplates>. When i work with an object in the Model, this working object is also in the OberservableCollection. I just use a reference. So that is it for rampup.

Now here is what I am seeing trouble. When I update the properties of the working object from the ViewModel.Model.WorkingObject.Property, the INotifyPropertyEvents fire and I have verified this. So say i set the properties of the working object to ""  or null. These raise the INotifyPropertyChanged Events in the properties of the working object fire, however the UI controls that are bound to these properties do not update.

Here is a sample UI control:

            <StackPanel Grid.Row="0">
                <TextBlock Text="Title (max 60):" 
			               Style="{StaticResource PhoneTextTitle2Style}" />
                <ScrollViewer VerticalScrollBarVisibility="Visible" Height="60" >
                    <TextBox Text="{Binding model.workingTimeSlotTemplate.TitleText, Mode=TwoWay}" 
                             TextWrapping="Wrap" MaxLength="60" />
                </ScrollViewer>
            </StackPanel>

Here is the property definition in the class:
 
    public class TimeSlotTemplate : NotifyBase
    { 
         public String TitleText
        {
            get { return titleText; }
            set
            {
                if (titleText != value)
                {
                    titleText = value;
                    OnPropertyChanged("TitleText");
                }
            }
        } 
    ...
   }

 Any ideas? I know its not a bug in WP7 because my previous application did not use MVVMLight and updating properties worked properly.
Thank you in advance for your help! BTW awesome MVVMLight keep improving it etc. 
Coordinator
Jun 22, 2011 at 8:17 PM

Hi,

I don't have enough info to spot the problem. Can you post a repro?

Do you modify the ObservableCollection after it is data bound?

Thanks,

Laurent

Jun 22, 2011 at 8:22 PM
Edited Jun 22, 2011 at 8:55 PM

I just add new objects to the collection as i need ObservableCollection<TimeSlotTemplates>.Add(TimeSlotTemplate) then properties are updated to that object in the collection.

I am removing the reference to the working object in the collection and do work on the object directly. Once it is ready for save, I am going to add it to the collection for processing.

I will let you know what I find.

Jun 23, 2011 at 6:23 AM

You can bitch slap me now. The base class's RaisePropertyChanged Event was not being called. I made new classes and forgot to call the base class method properly. Sorry to waste your very valuable time and thank you for answering so quickly.

Coordinator
Jun 30, 2011 at 10:09 AM

Done ;) Thanks for reporting!

Cheers,

Laurent