Hii,
I've my custom Control in which, i'm defining a static contextMenu to its one of the template part control. For e.g. Look at the code below.
<ControlTemplate TargetType="Controls:MyCustomControl"><Border BorderBrush="{TemplateBinding BorderBrush}"><ScrollViewer x:Name="PART_ScrollViewer" Focusable="false" CanContentScroll="True"><ScrollViewer.Template><ControlTemplate TargetType="{x:Type ScrollViewer}"><Grid><Grid.Resources><!--Start: TopRightHeaderTemplate--><ControlTemplate x:Key="TopRightHeaderTemplate" TargetType="ColumnHeader"><Grid Name="RootElement"><Grid.RowDefinitions><RowDefinition/><RowDefinition Height="Auto" /></Grid.RowDefinitions></Grid></ControlTemplate><!--End: TopRightHeaderTemplate--></Grid.Resources><Grid.RowDefinitions><RowDefinition Height="Auto" /><RowDefinition Height="*" /><RowDefinition Height="Auto" /></Grid.RowDefinitions><Button x:Name="PART_SelectAllButton" Command="{x:Static DataGrid.SelectAllCommand}" Focusable="false" ControlHelpers:ControlsHelper.MouseRightButtonDownCommand="" Style="{DynamicResource {ComponentResourceKey ResourceId=SelectAllButtonStyle, TypeInTargetAssembly={x:Type Controls:MyCustomControl}}}" Visibility="{Binding HeadersVisibility, ConverterParameter={x:Static DataGridHeadersVisibility.All}, Converter={x:Static DataGrid.HeadersVisibilityConverter}, RelativeSource={RelativeSource AncestorType={x:Type Controls:MyCustomControl}}}" Width="{Binding CellsPanelHorizontalOffset, RelativeSource={RelativeSource AncestorType={x:Type Controls:MyCustomControl}}}" ><Button.ContextMenu><ContextMenu x:Name="cntxMenuSelectAllButton"><MenuItem x:Name="menuItemExportTo" Header="Export to" Visibility ={Binding CanUserSearch, RelativeSource={RelativeSource AncestorType={x:Type Controls:MyCustomControl}}, Converter={StaticResource boolToVisibilityConvertor}}"><MenuItem x:Name="menuItemExportToExcel" Header="Excel format" Command="{x:Static Controls:MyCustomControl.ExportToExcelCommand}"></MenuItem></MenuItem></ContextMenu></Button.ContextMenu>
Look at the property i binded with the Context menu's meuItem "CanUserSearch". I if i set its value to "False", this menu items should not be visible while Running the application. But However, i don't know why i'm not getting the reflection on the context menu Item. (CanUserSearch is depedency property).
Currently i've managed to show/hide that menuItems through code but i know this can be done by direct binding a property.
Its very urgent, anyone can halp please?
Thanks.