Documentposition of Span

3 posts, 1 answers
  1. JoRoSch
    JoRoSch avatar
    8 posts
    Member since:
    Dec 2011

    Posted 03 Jul 2013 Link to this post

    Hi everybody,
    how can I retrieve the documentposition of a certain Span (not the current where the caret is in). The background is: I need to move the caret to a specific Span when pushing the FastForward / FastRewind button of a microphone to easily dictat in a RadRichTextBox.

    Here is what I have yet:

    List<NamedPermissionRangeStart> allPermissionRangeStarts = Document.EnumerateChildrenOfType<NamedPermissionRangeStart>().SkipWhile(a => a.Type != "Text").ToList();
                NamedPermissionRangeStart cur = (NamedPermissionRangeStart)Document.CaretPosition.GetCurrentSpanBox().AssociatedSpan.PreviousSibling;
     
                for (int i = 0; i < allPermissionRangeStarts.Count; i++)
                {
                    if (allPermissionRangeStarts[i].InternalKey == cur.InternalKey)
                    {
                        Document.CaretPosition.MoveToPosition(((Span)allPermissionRangeStarts[i + 1].NextSibling).?????)
                        break;
                    }
                }


    I hoped to find something that gives me the DocumentPosition where the "???" are.
    Is this approach the right one?

    Thanks in advance
    Jo
  2. Answer
    Boby
    Admin
    Boby avatar
    595 posts

    Posted 05 Jul 2013 Link to this post

    Hello JoRoSch,
    You can use DocumentPosition.MoveToInline(...) methods to navigate document position to any Inline, including Span-s and NamedPermissionRangeStart-s.

    Regards,
    Boby
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  3. UI for WPF is Visual Studio 2017 Ready
  4. JoRoSch
    JoRoSch avatar
    8 posts
    Member since:
    Dec 2011

    Posted 08 Jul 2013 Link to this post

    thanks for this hint, helped a lot.
Back to Top