Form is always readonly?

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

    Posted 14 Aug 2012 Link to this post

    I have a RadDataForm on which some DataFormDataField fields seemed to be read-only.

    Using Snoop, I discovered that the form's mode is ReadOnly.

    Now here's the thing.  I had AutoEdit="True" in the xaml.  I've tried setting AutoEdit and calling BeginEdit() in the constructor, and in DataContextChanged, both, and neither seems to make any difference.  Both in the constructor and in DataContextChanged, CanBeginEdit is false.

    What could be going on that would cause CanBeginEdit to be false?

    The form is bound to its DataContext, via CurrentItem="{Binding Path=.}"

  2. Jeff
    Jeff avatar
    64 posts
    Member since:
    Dec 2011

    Posted 14 Aug 2012 Link to this post

    Two observations:

    First, by explicitly embedding a TextBox as the content for a DataFormDataField, you can bypass this problem.  That is, instead of:

    <telerik:DataFormDataField
        DataMemberBinding="{Binding Quantity}"
        />
    do this:
    <telerik:DataFormDataField>
        <TextBoxText="{Binding Quantity}"/>
    </telerik:DataFormDataField>

    That's not really much of a solution, though.  It works because we're using non-telerik data fields that ignore whether the form is in readonly or edit mode.

    My best guess at the real problem is that we're binding CurrentItemProperty to the viewmodel in the xaml, at a point at which the viewmodel hasn't yet been set.  What works, and seems to be the correct solution is to bind CurrentItemProperty in DataContextChanged.  If I do this, and have AutoEdit="True", the form is in edit mode, when it opens.
  3. UI for WPF is Visual Studio 2017 Ready
  4. Ivan Ivanov
    Admin
    Ivan Ivanov avatar
    1127 posts

    Posted 15 Aug 2012 Link to this post

    Hello Jeff,

    There are few other factors that affect a fields IsReadOnly state, aside from RadDataForm's Mode setting. I presume RadDataForm's data engine considers these properties to be ReadOnly properties. Would you please check for any noticeable reasons for this in their definition? In case that the issue persists, would it be possible for you to send us a sample project that we could debug on our side?

    All the best,
    Ivan Ivanov
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top