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

converting from DataGrid RowLoaded to TreeListView ItemPrepared

1 Answer 73 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Rami Abughazaleh
Top achievements
Rank 1
Rami Abughazaleh asked on 09 Jun 2010, 02:03 AM
Hi.

[Edit] Sorry, I should have posted this in the TreeListView forum.

When working with a datagrid, I was able to programmatically access the row and cell templates as follows:
private void DataGrid_RowLoaded(object sender, Telerik.Windows.Controls.GridView.RowLoadedEventArgs e)
        {
            MyEntityObject entity = (MyEntityObject)e.Row.Item;
            if (entity != null)
            {
                if (entity.some_property == "some_value")
                {
                    BitmapImage bitmapImageSource = new BitmapImage(new Uri("images/some_image.png", UriKind.Relative));
                    var someImage = e.Row.ChildrenOfType<Image>().Where(c => c.Name == "some_image").FirstOrDefault();
                    someImage.Source = bitmapImageSource;
                }
            }
        }

How can I do this in a TreeListView?

private void TreeListView_ItemPrepared(object sender, RadTreeViewItemPreparedEventArgs e)
        {
            MyEntityObject entity = (MyEntityObject)e.PreparedItem.Item;
            if (entity.some_property == "some_value")
            {
                    BitmapImage bitmapImageSource = new BitmapImage(new Uri("images/some_image.png", UriKind.Relative));

                    var someImage = ((RadTreeListView)sender).ChildrenOfType<Image>().Where(c => c.Name == "some_image").FirstOrDefault(); //this just selects the first item at the very top of the tree list view
                    someImage.Source = bitmapImageSource;
                }
        }

I tried to replace .FirstOrDefault() with .ElementAt(e.PreparedItem.Index) but e.PreparedItem.Index is not guaranteed to be the correct index of the item from the lambda expression.

Any ideas?

Using Telerik Silverlight Controls v2010.1.422.1040

Thank you.

1 Answer, 1 is accepted

Sort by
0
Valentin.Stoychev
Telerik team
answered on 09 Jun 2010, 07:04 AM
Hello Rami Abughazaleh,

This week we will release a new version of the RadTreeListView where it will have breaking changes from the previous version. The new version will behave it the same way like the gridview control. It is recommended to download the new version and stop using the old one.

All the best,
Valentin.Stoychev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
TreeView
Asked by
Rami Abughazaleh
Top achievements
Rank 1
Answers by
Valentin.Stoychev
Telerik team
Share this question
or