I am trying to set a complete set of controls inside a read-only panel (for example, if the user does not have permission to edit) through data binding and an attached property. (I know that setting the panel to disable also disables its children, but that's too much, since it also disables hyperlinks, lists, etc.)
Basically, the handler of the processed property changed the visual tree and found all TextBox children, and then set the IsReadOnly property to both true and false. This works, but does not apply to the case when the TextBox already has an IsReadOnly parameter - either const or binding. For example, if a TextBox should always be read-only, then the attached property should not change it to true. In addition, if the TextBox has a binding that in some cases restricts the TextBox to read-only, the attached property should not blindly set true or false, but rather combine the parameters, that is, if the attached AND property of the text field binding indicates a read-only , then it is editable, otherwise it is read-only.
How can I do that? This will require somehow to get the current IsReadOnly setting (binding, markup, constant value, etc.) and replace it with a shell that performs an AND combination. How to get current parameter / value source for dependency property? I looked at the following, but I don’t see how it will solve my problem:
TextBox1.GetValue(TextBoxBase.IsReadOnlyProperty);
DependencyPropertyHelper.GetValueSource(TextBox1, TextBoxBase.IsReadOnlyProperty);
TextBox1.GetBindingExpression(TextBoxBase.IsReadOnlyProperty);
Any help would be appreciated.
J.-
EDIT: I'm looking for something like
(pseudo-code)
TextBox1.IsReadOnly := OR(TextBox1.IsReadOnly, GlobalIsReadOnly)
which now sets the TextBox1.IsReadOnly value to true if the GlobalIsReadOnly flag is set or the TextBox1.IsReadOnly value indicates read-only, be it binding, markup, or constant.