The problem is that when we're displaying a RadDataForm with IsEnabled="False", they are unable to select the text on the form and copy it to the clipboard. Which, apparently, is a significant problem for them.
It's an easy enough problem to replicate. You can see it in your example at https://github.com/telerik/xaml-sdk/tree/master/DataForm by simply setting IsEnabledFalse="True" on the RadDataForm.
Is there another simple way of making a form readonly, that doesn't cause this problem?
10 Answers, 1 is accepted
The IsEnabled property is automatically propagated to the child controls, by the framework itself. Have you considered using RadDataForm in read-only mode instead (Mode=ReadOnly)? In this mode selection for TextBox editors is supported.
Regards,
Ivan Ivanov
Telerik
The product we were working on when I asked this question was shelved, because of new priorities and serious doubts about whether we actually needed it.
Now I suddenly have to get it out, brush it off, and fix a couple of issues, so we can show it off at a user conference next week. Number one on the list of issues is this.
I've pretty much forgotten everything I knew about WPF, but I'm trying to figure it out, again.
I've dug through the UI tree using Snoop, and confirmed that IsEnabled=False for the controls in question. Then, just as an experiment, I hard-coded IsEnabled=True in the XAML declaration for the form. Snoop now indicates that IsEnabled=True for the controls - and they still can't be selected.
I vaguely remember having had to change the transparency on a layer that you draw over the top of the form, when the form was disabled, to keep people from interacting with it. Could something like that be in place, that would keep me from selecting the text?
I am sending you a sample project which demonstrates the approach that my colleague Ivan had suggested - using ReadOnlyTemplate instead of setting IsEnabled=False. In the sample project you will see the difference between the two approaches.
If you need further assistance on this, do not hesitate to contact me again.
Regards,
Yoan
Telerik
I can see in your sample project the disabled form and the read-only form, and I can see that the fields are selectable, but not editable, in the read-only form which is the behavior I want.
But here's the thing - on digging deeper I'm not sure the form I was talking about is not IsEnabled=false. Or, at least, I can't find the code that's doing it. It is setting its ReadOnlyTemplate, as you suggested. But the fields are still not selectable.
When I look at the disabled form in your demo in Snoop, I see a Border named "Background_Disabled". When I look at my form I do not. And again, in snoop, the form's IsEnabled flag is true. When I navigate down the UI tree, I see that the grids on the form are enabled, but the individual textBoxes are not.
Any idea what could be disabling them?
Never mind. After that bit of exploration, I was able to find the bit of markup that was disabling the fields - we had a style applied.
The problem now is that if I remove the style, the fields are editable, despite the template being loaded via the form's ReadOnlyTemplate.
Is this something that might have changed, between the version we're using (2012.3.1017.40) and the one your demo uses (2015.2.623.40).
Indeed, the change is from our side. We had changed the ReadOnly state of some controls. However, in your case the editor, when using the ReadOnlyTemplate is not editable.
Regards,
Yoan
Telerik
I clearly must be misunderstanding something. We've been loading a form with only its ReadOnlyTemplate set, yet the TextBoxes could be manipulated - characters entered, deleted, etc., and the ChecklBoxes could be checked and unchecked. Because of this, we had d​isabled them:
<
Grid.Resources
>
<
Style
TargetType
=
"TextBox"
>
<
Setter
Property
=
"IsEnabled"
Value
=
"False"
/>
</
Style
>
<
Style
TargetType
=
"CheckBox"
>
<
Setter
Property
=
"IsEnabled"
Value
=
"False"
/>
</
Style
>
</
Grid.Resources
>
This prevented the user from making changes to the fields, but made it impossible to copy the text to the clipboard. I'd thought, from this thread and reading through the version notes, that this might have been fixed in a more recent version.
So this morning, I updated our project to 2015.2.728.40, and removed the above Styles.
Result? The TextBoxes are still active and can be edited.
This is strange. I had tested the sample project which I sent you with your version - 2012.3.1017.40 and the editors are not editable. Also, they are not editable using our latest version - 2015.2.728.40 . Unfortunately with the supplied information I cannot figure out what is going on. Could you please try to isolate the problem you have in the sample project from my previous reply? Then you can send it to me for further investigation.
Regards,
Yoan
Telerik
I am glad to hear that. If you need further assistance on this, do not hesitate to contact me again.
Regards,
Yoan
Telerik