I have a View that is of type telerikDocking:RadDocumentPane. The first visual element on this view, and the container for all other visual elements, is a Grid with x:Name="MainGrid".
If I bind a property of the Grid to a public property on the ViewModel which is its DataContext, it works and sees it.
Inside this grid is a telerik:RadGridView and one of its columns is a Delete button whose visibility property is bound to the IsSelected property of the GridviewRow. That works fine as well.
I need to be able to override that Visibility of the button based on other criteria that is handled in a public property on the ViewModel. To accomplish this, I wrapped the button in a StackPanel and am trying to bind its Visibility to the ViewModel's public property and no matter what RelativeSource syntax I use, I cannot get to that property on the VieModel.
Here is the XAML for delete button:
<telerik:GridViewDataColumn>
<telerik:GridViewDataColumn.CellTemplate>
<DataTemplate>
<StackPanel Visibility="{Binding ???}">
<telerik:RadButton Width="70"
Command="telerik:RadGridViewCommands.Delete"
CommandParameter="{Binding}"
Content="Delete"
IsEnabled="{Binding UserHasCofundingRole}"
Visibility="{Binding IsSelected,
RelativeSource={RelativeSource AncestorType={x:Type telerik:GridViewRow}},
Converter={StaticResource booleanToVisibilityConverter}}" />
</StackPanel>
</DataTemplate>
</telerik:GridViewDataColumn.CellTemplate>
</telerik:GridViewDataColumn>
Here are all the binding syntax attempts that I have tried for the StackPanel's Visibility but none ever hit the ViewModel:
{Binding DataContext.DeleteButtonVisible, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type telerikDocking:RadDocumentPane}}, Converter={StaticResource booleanToVisibilityConverter}}
{Binding ViewModel.DeleteButtonVisible, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type telerikDocking:RadDocumentPane}}, Converter={StaticResource booleanToVisibilityConverter}}
{Binding ElementName=MainGrid, Path=DataContext.DeleteButtonVisible, Converter={StaticResource booleanToVisibilityConverter}}
{Binding ElementName=LayoutRoot, Path=ViewModel.DeleteButtonVisible, Converter={StaticResource booleanToVisibilityConverter}}
{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=DataContext.DeleteButtonVisible, Converter={StaticResource booleanToVisibilityConverter}}