This is a migrated thread and some comments may be shown as answers.

Could I Set TreeListView's Row Properties like this?

4 Answers 59 Views
TreeListView
This is a migrated thread and some comments may be shown as answers.
Yu
Top achievements
Rank 1
Yu asked on 06 Dec 2011, 11:36 AM
Hi,I'm using RadTreeListView,the default TreeListViewRow's IsExpanded Property is controled by a toggle button,right?
My question is:
when the IsSelected property is True,Could I give the IsExpanded property a True Value,too?It means the Row Expanded when I Selected the Row.

best wishes,
Sky

4 Answers, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 08 Dec 2011, 05:01 PM
Hi Yu,

 You could do this like so:

private void tlv_SelectionChanged(object sender, SelectionChangeEventArgs e)
       {
           if (e.AddedItems.Count > 0)
           {
               TreeListViewRow selectedRow = this.tlv.ItemContainerGenerator.ContainerFromItem(e.AddedItems[0]) as TreeListViewRow;
               if (selectedRow != null)
               {
                   selectedRow.IsExpanded = true;
               }
           }

That way when a row is selected, it will be expanded.

Regards,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Yu
Top achievements
Rank 1
answered on 09 Dec 2011, 11:22 AM
Hello,
Thanks for your reply,and this works! Thank you very much.But,it only happens when the selection changes,how could it happens when the row is clicked?

Best Regards,
Sky
0
Accepted
Dimitrina
Telerik team
answered on 13 Dec 2011, 10:11 AM
Hello Yu,

If you want to set the row properties when the row is clicked, then you should handle the click. I would suggest you something like this:

public MainWindow()
       {...
           this.AddHandler(FrameworkElement.MouseDownEvent, newSystem.Windows.Input.MouseButtonEventHandler(OnMouseDown), true);
       }
    
       private void OnMouseDown(objectsender, MouseButtonEventArgs e)
       {
           var s = e.OriginalSource asFrameworkElement;
           var parentRow = s.ParentOfType<GridViewRow>();
           if(parentRow != null)
           {... }
}

I hope that this is what you need.

Best wishes,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Yu
Top achievements
Rank 1
answered on 13 Dec 2011, 10:52 AM
Hello,
It's done! It works well!Thank you very much and best wishes to you and Telerik Team!

Sky
Tags
TreeListView
Asked by
Yu
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Yu
Top achievements
Rank 1
Share this question
or