Gridview command binding not working for cell template

1 Answer 92 Views
Top achievements
Rank 1
onkar asked on 11 Aug 2021, 02:15 PM


I am using wpf grid view as shown below. 

 <telerik:RadGridView Grid.Row="1" ItemsSource="{Binding ExistingFilesCollection}" CanUserDeleteRows="False" CanUserFreezeColumns="False" CanUserGroupColumns="False" CanUserInsertRows="False" CanUserReorderColumns="False" CanUserSearch="False" ShowGroupPanel="False" IsFilteringAllowed="False" 
                             AutoGenerateColumns="False" SelectionMode="Extended"   Margin="0,10,0,0" GridLinesVisibility="Both" RowIndicatorVisibility="Collapsed">
                <telerik:GridViewDataColumn DataMemberBinding="{Binding Selected, Mode=TwoWay}"  IsSortable="False">
                            <CheckBox  IsChecked="{Binding DataContext.SelectAll, ElementName=ExistingFilePopUpRoot,Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
                            <CheckBox  IsChecked="{Binding Selected, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Command="{Binding RelativeSource={RelativeSource AncestorType={x:Type Grid},AncestorLevel=4}, Path=DataContext.CheckBoxEvent}" CommandParameter="{Binding RelativeSource={RelativeSource AncestorType={x:Type Grid},AncestorLevel=4}, Path=DataContext}"   />

I don't want to use GridviewCheckboxcolumn or select column since it doesn't fit my requirement.

Now the issue is when I do databinding based on element name it fails but as shown above based on ancestor level it works.

Is there a way I can do command binding based on elementname?

1 Answer, 1 is accepted

Sort by
Martin Ivanov
Telerik team
answered on 16 Aug 2021, 08:18 AM

Hello Onkar,

ElementName binding doesn't work outside of its namescope. In other words, in the common case you cannot access elements outside of the template where the ElementName binding is used. Using the RelativeSource is the way to go here. Or alternatively, you can try the x:Reference keyword instead of ElementName.

Martin Ivanov
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at

Asked by
Top achievements
Rank 1
Answers by
Martin Ivanov
Telerik team
Share this question