Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
990
getting a grid to accept return
posted

How do I get a xamdatagrid field to accept returns as part of the input, instead of finishing the edit?

 I can't see a property on XamTextEditor to do this.

Thanks

Parents
  • 990
    posted

    I have a hack if there isn't an elegent solution:

    Style the XamTextEditor to call an event when edit mode starts:

    <my:Field Name="Name">
    <my:Field.Settings>
    <my:FieldSettings EditorType="{x:Type igEditors:XamTextEditor}">
    <my:FieldSettings.EditorStyle>
    <Style TargetType="{x:Type igEditors:XamTextEditor}">
    <EventSetter Event="EditModeStarted" Handler="EditStarted" />
    </Style>
    </my:FieldSettings.EditorStyle>
    </my:FieldSettings>
    </my:Field.Settings>
    </my:Field>


    Then in the event handler, walk the visual tree to find the TextBox that's hanging off XamTextEditor, and set the AcceptReturns property:

    public void EditStarted(object sender, EditModeStartedEventArgs e)
    {
     TextBox b = (TextBox)VisualTreeWalker.FindFirst((Visual)e.Source, typeof(TextBox));
     b.AcceptsReturn = true;
    }

    I haven't included VisualTreeWalker here, but it's simple enough code.

    Any better solution?

    Thanks,

    John

Reply Children