Avag Akopov
Avag Akopov

Reputation: 33

RadGridView Button Column Content Binding to DataMember

I have a telerik rad grid view and assigned buttons to one of the columns using DataTemplate.

        <telerik:RadGridView ItemsSource="{Binding AllJobsCollection}" 
                         Grid.Row="2"
                         SelectedItem="{Binding SelectedJob}">

        <!--Jobs List Columns-->
        <telerik:RadGridView.Columns>

            <!--Pin button Column-->
            <telerik:GridViewColumn>
                <telerik:GridViewColumn.CellTemplate>
                    <DataTemplate>
                        <telerik:RadButton
                            Command="{Binding Path=DataContext.PinCommand, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type telerik:GridViewDataControl}} }"            
                            CommandParameter="{Binding}">
                        </telerik:RadButton>
                    </DataTemplate>
                </telerik:GridViewColumn.CellTemplate>
            </telerik:GridViewColumn>

            <telerik:GridViewDataColumn Header="Job" 
                                        Width="Auto"
                                        IsReadOnly="False"
                                        DataMemberBinding="{Binding Name}"/>

        </telerik:RadGridView.Columns>
    </telerik:RadGridView>

My question is how can I set the content of the button using DataMemberBinding.

I have a data table and i can pin some of the items and i change their Pinned property in database. I want to get the pinned property and set the buttons content accordingly.

Upvotes: 2

Views: 1465

Answers (1)

mm8
mm8

Reputation: 169270

You can't use DataMemberBinding within a CellTemplate. But you can bind the Content property to the any property of the current item, e.g.:

<telerik:RadButton
    Command="{Binding Path=DataContext.PinCommand, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type telerik:GridViewDataControl}} }"            
    CommandParameter="{Binding}"
    Content="{Binding IsPinned}">

Upvotes: 1

Related Questions