I have a form in my WPF application that I have to add an Edit button to. Right now, the form is always in edit mode and there is no "view mode". However, for various reasons, I need to keep the control in view mode until the user clicks an Edit button, and then hide the edit button and display a Save button in its place.
My form already has a bool DependencyProperty
called CanModify
, which is true when the user's permissions give them the right to edit the record being displayed in the form. I am adding a new bool DependencyProperty
called InEditMode
, which will default to false. Hiding and enabling the buttons is pretty straight forward, but I have this ComboBox
control that I want to hide if the user can't edit the record, or if they can edit it and the form is in view mode. For that, I need to convert the result of ANDing the two bool properties together and then convert it into a Visibility
value.
I've already got a class that implements IValueConverter
and converts a bool into a Visibility
. I've just written a class that implements IMultiConverter
which takes an array of bools and ANDS them together (or ORs them, depending on the value of the parameter).
What I'd like to do is to take the result of the IMultiConverter
and put it through the IValueConverter
to convert the result into a Visibility
. Can I do that? Or would I be better off doing the AND in the code behind to a new DependencyProperty
?
Tony
Because you can't chain converters, I added another boolean property to my class. I added methods to the two properties the new one is dependent upon that are called when they change. These recompute the value of the new property. I then used my original boolean to visbility converter to show or hide the control in question.