Making a form readonly without disabling it?

11 posts, 0 answers
  1. Jeff
    Jeff avatar
    64 posts
    Member since:
    Dec 2011

    Posted 12 Jun 2014 Link to this post

    We have a complaint from a customer, and aren't sure of how to deal with it.

    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?
  2. Ivan Ivanov
    Admin
    Ivan Ivanov avatar
    1127 posts

    Posted 17 Jun 2014 Link to this post

    Hi Jeff,

    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
     
    Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
     
  3. UI for WPF is Visual Studio 2017 Ready
  4. Jeff
    Jeff avatar
    100 posts
    Member since:
    Apr 2008

    Posted 22 Sep 2015 in reply to Ivan Ivanov Link to this post

    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?

  5. Yoan
    Admin
    Yoan avatar
    1068 posts

    Posted 23 Sep 2015 Link to this post

    Hello Jeff,

    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
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  6. Jeff
    Jeff avatar
    100 posts
    Member since:
    Apr 2008

    Posted 24 Sep 2015 Link to this post

    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?

  7. Jeff
    Jeff avatar
    100 posts
    Member since:
    Apr 2008

    Posted 24 Sep 2015 in reply to Jeff Link to this post

    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).

  8. Yoan
    Admin
    Yoan avatar
    1068 posts

    Posted 29 Sep 2015 Link to this post

    Hello Jeff,

    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
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  9. Jeff
    Jeff avatar
    64 posts
    Member since:
    Dec 2011

    Posted 29 Sep 2015 in reply to Yoan Link to this post

    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.

     

     

     

     

  10. Yoan
    Admin
    Yoan avatar
    1068 posts

    Posted 30 Sep 2015 Link to this post

    Hello Jeff,

    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
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  11. Jeff
    Jeff avatar
    64 posts
    Member since:
    Dec 2011

    Posted 30 Sep 2015 in reply to Yoan Link to this post

    I've found a work-around - I have my style set IsReadOnly=true, instead of IsEnabled=false, for the textboxes.  CheckBoxes don't seem to accept that, so I'm still using IsEnabled=False for them. Which isn't ideal (colors change) but we can live with it.
  12. Yoan
    Admin
    Yoan avatar
    1068 posts

    Posted 01 Oct 2015 Link to this post

    Hi Jeff,

    I am glad to hear that. If you need further assistance on this, do not hesitate to contact me again.

    Regards,
    Yoan
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top
UI for WPF is Visual Studio 2017 Ready