item offset position

4 posts, 0 answers
  1. robert
    robert avatar
    27 posts
    Member since:
    Aug 2011

    Posted 02 Oct 2012 Link to this post

    hello, how can i get the item offset position. I want to search a item with getitembypath and
    scroll the item to the middel of the treeview with the vertical offset function. How can i do this?
    thank you ...
  2. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 02 Oct 2012 Link to this post

    Hello Robert,

     If you need to scroll to the item you've got by the GetItemByPath, you better use the BringPathintoViewMethod() which performs these two tasks:
    1) Generates the containers needed along the path to the given item
    2) Brings the item into view (expanding and scrolling to the item).
    Please check out the following help article and let us know how it goes.

    Regards,
    Petar Mladenov
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. UI for WPF is Visual Studio 2017 Ready
  4. robert
    robert avatar
    27 posts
    Member since:
    Aug 2011

    Posted 02 Oct 2012 Link to this post

    Thank you for your help. When i use BringPathIntoView the node is expanded and shown as last entry (vertical) of the treeview window. I want that the item is shown in the middle of the treeview window (when enough notes behind are available) not on last position, i. e. verticaloffset node position + 500. How can i do this?
    Please see attached screenshots.
    Thank you ...
  5. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 05 Oct 2012 Link to this post

    Hi Robert,

     When the item in question has  children , you can set the RadtreeView's property BringIntoViewModel to "HeaderAndItems";

    <telerik:RadTreeView x:Name="treeView"  PathSeparator="|" BringIntoViewMode="HeaderAndItems">
    which will scroll so that the child items of the brought item will be visible.
    When it has no children , you have to perform this scrolling on your own, and this is not so easy, because you need to wait for the Bring operation to finish. You can try with Dispatcher like so:
    private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            this.treeView.BringPathIntoView("Item 2|Item 2.1|Item 2.1.3");
            RadTreeViewItem container = this.treeView.GetItemByPath("Item 2|Item 2.1|Item 2.1.3");
            container.IsSelected = true;
            Dispatcher.BeginInvoke(new Action(()=>
            {
                this.treeView.ScrollViewer.ScrollToVerticalOffset(this.treeView.ScrollViewer.VerticalOffset + this.treeView.ScrollViewer.ViewportHeight/2);
            }), DispatcherPriority.ApplicationIdle);
        }
    This is also demonstrated in the attached project.

    Greetings,
    Petar Mladenov
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top