Visibility and bool

Sep 27, 2010 at 2:11 PM

Hi guys!

Do you know how to deal with Visibility and bool values? I would like to be able to set Visibility to true and false.

One way would be to use my ViewModel to convert my bool values to strings but then I will have to deal with two variables for all my hideable elements in all my ViewModels, which seems like a lot for such a small thing.

The other way would be to use a valueconverter, but I read somewhere that a ViewModel is a valueconverter on steroids, so perhaps using MVVM and valueconverters is no good.

I also remember Eisenberg mentioning something about this in a speech so perhaps Caliburn have some default way of handling this.

Anyone knows anything about this?

Thanx

/Mike

Coordinator
Sep 27, 2010 at 2:41 PM

Certain elements, such as Panels, have their conventional bind property set to Visibility. In this case, if you name it the same as a bool property on your VM, it will bind and automatically perform the value conversion. Otherwise, I recommend just using the value converter for these scenarios. WPF has one OOTB and CM provides one for SL and WP7.

Sep 27, 2010 at 5:09 PM

Ok, great. There are a few panels and some textboxes so x:Name for the panels and value converter for the textboxes then.

Thanx

/Mike