Property Status problems

Property Status problems

Old forum URL:

hanspret posted on Thursday, October 07, 2010


How do one refresh the property status in WPF. 

I have a button where the user can cancel edit. I call CancelEdit on the object and set the object to null all the controls behave like expected except the Property Status control. It keep on showing the Business Rule Error image. Like I said I even tried refresing the DataContext of the Grid but nothing happens.

RockfordLhotka replied on Thursday, October 07, 2010

What version of CSLA are you using? There was a bug for a while that caused this behavior, but it is fixed in the most current version.

hanspret replied on Thursday, October 07, 2010

I am using the newest version 4.0.1. but I got a workaround.


The problem was:

When you set the datacontext of a grid the propertyStatus works well by checking the Business rules and displaying the error icon. In my case when the user hit cancel I do the following:

MyController.SelectedBudget = null;

grdMain.DataContext = MyController.SelectedBudget

By setting the DataContext effectively null (SelectedBudget is null) the propertyStatus didn't update and the error message still displayed on the screen.

My Work around:

I modified the GoToStatus method on the PropertyStatus class in Csla.Xaml to the following:

  protected virtual void GoToState(bool useTransitions)



                if (_loading) return;


                BusyAnimation busy = FindChild(this, "busy") as BusyAnimation;

                if (busy != null)

                    busy.IsRunning = IsBusy;


                string newState;

                if (IsBusy)

                    newState = "Busy";

                else if (IsValid || DataContext == null)

                    newState = "PropertyValid";


                    newState = RuleSeverity.ToString();


I don't know if this is the right way but it is working for me. My thinking was, if datacontext is null clear all error messages

RockfordLhotka replied on Thursday, October 07, 2010

That shouldn't be necessary. When you call CancelEdit that will cause OnUnknownPropertyChanged to be called, which will basically cause all bound properties to refresh. That should trigger PropertyStatus to re-read the object's metastate.

The only thing I can think, is that maybe there's a bug in PropertyStatus where it doesn't refresh if the PropertyName provided from the event is null or string.Empty - which is what'll happen on a cancel.

JonnyBee replied on Thursday, October 07, 2010

PropertyStatus checks for both PropertyName and "empty" propertyName so it should work fine with OnUnknownPropertyChanged:

    void source_PropertyChanged(object sender, PropertyChangedEventArgs e)
      if (e.PropertyName == BindingPath || string.IsNullOrEmpty(e.PropertyName))

RockfordLhotka replied on Thursday, October 07, 2010

I thought so - primarily because I have apps where this is all working just fine.

So then I suggest that there's something strange with the way you are using CancelEdit or have your bindings set up. Are you using a CslaDataProvider or a ViewModel<T> or something else?

Copyright (c) Marimer LLC