I am trying to pass the sender (control i.e. a Radpane from where the context menu was invoked) as command parameter.
The code is as follows:
The code is as follows:
<
Window.DataContext
>
<
ViewModel:MainWindowViewModel
x:Name
=
"ViewModelContext"
>
<
ViewModel:MainWindowViewModel.ContextMenuTemplate
>
<
DataTemplate
>
<
tel:RadContextMenu
>
<
tel:RadMenuItem
Header
=
"Floating"
Command
=
"tel:RadDockingCommands.Floating"
/>
<
tel:RadMenuItem
Header
=
"Dockable"
Command
=
"tel:RadDockingCommands.Dockable"
/>
<
tel:RadMenuItem
Header
=
"Save"
Command
=
"{Binding Save}"
/>
<
tel:RadMenuItem
Header
=
"Close"
Command
=
"{Binding Close}"
CommandParameter
=
"{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type tel:RadPane}}}"
/>
</
tel:RadContextMenu
>
</
DataTemplate
>
</
ViewModel:MainWindowViewModel.ContextMenuTemplate
>
<
ViewModel:MainWindowViewModel.PaneHeaderTemplate
>
<
DataTemplate
>
<
StackPanel
Orientation
=
"Horizontal"
>
<
ContentPresenter
Content
=
"{Binding}"
Width
=
"150"
ToolTip
=
"{Binding}"
/>
<
Button
Command
=
"{Binding DataContext.Close, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type tel:RadPane}}}"
CommandParameter
=
"{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type tel:RadPane}}}"
HorizontalAlignment
=
"Center"
VerticalAlignment
=
"Center"
ToolTip
=
"Close"
BorderThickness
=
"0"
Width
=
"16"
Height
=
"16"
>
<
Image
Source
=
"Resources\Images\ImgClose.png"
/>
</
Button
>
</
StackPanel
>
</
DataTemplate
>
</
ViewModel:MainWindowViewModel.PaneHeaderTemplate
>
</
ViewModel:MainWindowViewModel
>
</
Window.DataContext
>
I can't get this to working.
In the above PaneHeaderTemplate works fine but I am not able to pass the parameter for the ContextMenu Template.
Is there any different way to do this?