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

Binding to Image

1 Answer 143 Views
TreeListView
This is a migrated thread and some comments may be shown as answers.
Joel Palmer
Top achievements
Rank 2
Joel Palmer asked on 08 May 2015, 04:44 AM

Following something similar to your GridViewComboBoxColumn example I was able to get a column in the RadTreeListView working.  However, my cell template needs an Image to show up.  This data template doesn't work because the image is actually on the ItemType which is displayed successfully in the ComboBox... I don't know how to get that ItemType's Image to show up on the DataTemplate or even on a RadPropertyGrid.Item to display its properties when I select the Node:

Once again, thanks for your help,

Joel

<UserControl.Resources>
    <DataTemplate
        x:Key="FirstColumnCellTemplate">
        <StackPanel
            Orientation="Horizontal">
            <Image
                Source="{Binding Image, Mode=TwoWay}"/>
            <TextBlock
                Text="{Binding Name, Mode=TwoWay}"
                Margin="5"/>
        </StackPanel>
    </DataTemplate>
</UserControl.Resources>

 

 Tree:

<telerik:RadTreeListView
    x:Name="treeListView"
    AutoGenerateColumns="False"
    HorizontalAlignment="Stretch"
    VerticalAlignment="Stretch"
    CanUserFreezeColumns="False"
    CanUserReorderColumns="False"
    Grid.Row="1"
    Margin="5"
    IsReadOnly="{Binding Context.IsReadOnly}"
    ItemsSource="{Binding Path=Context.Hierarchy, Mode=TwoWay}"
    SelectedItem="{Binding Context.SelectedItem, Mode=TwoWay}"
    AutoExpandItems="True">
 
    <telerik:RadTreeListView.ChildTableDefinitions>
        <telerik:TreeListViewTableDefinition 
            ItemsSource="{Binding Children}"/>
    </telerik:RadTreeListView.ChildTableDefinitions>
    <telerik:RadTreeListView.Columns>
 
        <telerik:GridViewDataColumn
            DataMemberBinding="{Binding Name, Mode=TwoWay}"
            CellTemplate="{StaticResource FirstColumnCellTemplate}"
            IsReadOnly="False"
            Width="*"/>
 
        <telerik:GridViewComboBoxColumn
            x:Name="itemTypeColumn"
            Header="Item Type"
            DataMemberBinding="{Binding ItemTypeID, Mode=TwoWay}"
            DisplayMemberPath="Name"
            SelectedValueMemberPath="ID"
            SortMemberPath="Order"
            SortingState="Ascending"
            ItemsSource="{Binding TypeModel.Items, Mode=TwoWay}"
            Width="150"/>
 
        <telerik:GridViewDataColumn
            DataMemberBinding="{Binding IsActive, Mode=TwoWay}"
            Header="Include"/>
 
    </telerik:RadTreeListView.Columns>
</telerik:RadTreeListView>

1 Answer, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 12 May 2015, 10:36 AM
Hello Joel,

As to GridViewComboBoxColumn, you can check the Templating GridViewComboBoxColumn example. Basically, you can try specifying ItemTemplate, which also applies to the default editor of that column - RadComboBox.

As I understand your question is to the other column - GridViewDataColumn. Please note the its DataContext is the bound data item (corresponding to each GridViewRow), therefore you should configure the Binding based on that.

Regards,
Dimitrina
Telerik
 

See What's Next in App Development. Register for TelerikNEXT.

 
Tags
TreeListView
Asked by
Joel Palmer
Top achievements
Rank 2
Answers by
Dimitrina
Telerik team
Share this question
or