I am trying to set an entire set of controls within a panel to read-only (e.g. if a user has no permission to edit) through data-binding and an attached property. (I am aware of the fact that setting a panel to disabled also disables its children, but this is too much, since it would also disable hyperlinks, lists, etc.)
Basically, the property changed event handler iterates the visual tree and finds all TextBox children and then sets their IsReadOnly property to either true or false. This works, but does not cover the case where the TextBox already has a IsReadOnly setting - either const or binding. For example if a TextBox should always be read-only, then the attached property should not change it to true. Also if the TextBox has a binding that restricts the TextBox to read-only in some cases, the attached property should not blindly set true or false, but rather combine the settings, i.e. if attached property AND textbox binding indicate no read-only, then it is editible, otherwise it is readonly.
How can this be done? This would require to somehow get the current IsReadOnly setting (binding, markup, constant value, ...) and replace it with a wrapper which does the AND-combination. How do I get the current setting/value source for a dependency property? I looked at the following, but don't see how it would address my problem:
TextBox1.GetValue(TextBoxBase.IsReadOnlyProperty);
DependencyPropertyHelper.GetValueSource(TextBox1, TextBoxBase.IsReadOnlyProperty);
TextBox1.GetBindingExpression(TextBoxBase.IsReadOnlyProperty);
Any help would be appreciated.
J.-
EDIT: I am looking for something like
(pseudo-code)
TextBox1.IsReadOnly := OR(TextBox1.IsReadOnly, GlobalIsReadOnly)
which now sets the TextBox1.IsReadOnly to true if the GlobalIsReadOnly flag is set or if the TextBox1.IsReadOnly value indicates read-only, be it a binding, markup or const.