Binding to Image

2 posts, 0 answers
  1. Joel Palmer
    Joel Palmer avatar
    164 posts
    Member since:
    May 2009

    Posted 07 May 2015 Link to this post

    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>

  2. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 12 May 2015 Link to this post

    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.

     
  3. UI for WPF is Visual Studio 2017 Ready
Back to Top