converting from DataGrid RowLoaded to TreeListView ItemPrepared

2 posts, 0 answers
  1. Rami Abughazaleh
    Rami Abughazaleh avatar
    27 posts
    Member since:
    Feb 2010

    Posted 08 Jun 2010 Link to this post

    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.
  2. Valentin.Stoychev
    Admin
    Valentin.Stoychev avatar
    2198 posts

    Posted 09 Jun 2010 Link to this post

    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.
Back to Top