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.
[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.