WPF PropertyStatus - How to bind to set Visibility to Collapsed when no error?

WPF PropertyStatus - How to bind to set Visibility to Collapsed when no error?

Old forum URL: forums.lhotka.net/forums/t/8971.aspx


dagware posted on Saturday, May 22, 2010

I'm trying out the WPF PropertyStatus (CSLA 3.8.3). When the property is valid, I want the PropertyStatus to have its Visibility set to Collapsed. I figured I could do this via Binding, however, the IsValid property isn't a Dependency Property, so I don't think that will do the trick.

Am I missing something here? Should I just roll my own version?

Dan

RockfordLhotka replied on Saturday, May 22, 2010

You should be able to bind to Self and use the IsValid property of the PropertyStatus control itself, with a converter of course.

dagware replied on Saturday, May 22, 2010

Wow, really? I thought it would have to be a dependency property in order for it to work - otherwise how does WPF know when the value changes?

I know normal CSLA properties aren't dependency properties, but I thought the reason they work is the IBindable (or whatever it is) backing you provide. Am I wrong?

Obviously I can just try it and see, and I will, but I'm trying to learn at the same time. Any light you can shed would be greatly appreciated, as are, of course, all the great things you provide!

Dan

RockfordLhotka replied on Saturday, May 22, 2010

Dependency properties are nice, but are not required for most basic binding scenarios. If you want full bi-directional binding they are sometimes required.

But in your case you want simple property binding, and since PropertyStatus implements INotifyPropertyChanged it will work just fine.

dagware replied on Saturday, May 22, 2010

Ah, "INotifyPropertyChanged". That's what I wasn't taking into account.

Thanks for taking the time to explain it! And yes, it does indeed work.

Dan

Copyright (c) Marimer LLC