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
250
XamTextEditor cursor position
posted

 Hi,

 

I need to know the Cursor position of a XamTextEditor.

I can know only SelectionStart and SelectionLength.

Any suggests,

Thanks Andrea

  • 14517
    Offline posted

    Normal 0 false false false EN-US X-NONE X-NONE

    Hello,

    The XamTextEditor uses a TextBox (PART_FocusSite) when in edit mode and a TextBlock otherwise. With a normal textbox you can find the cursor position by using the SelectionStart property. When using the XamTextEditor this property can only be found from the underlying textbox when in edit mode, therefore the best option would be to capture this value when you are exiting edit mode. For example:

    private void xamEditor_EditModeEnding(object sender, Infragistics.Windows.Editors.Events.EditModeEndingEventArgs e)

    {

      TextBox tb = (TextBox) GetChild(xamEditor, "PART_FocusSite");

      startPos = tb.SelectionStart;      

    }

     

    Valerie