Hi Everyone,
I have created a custom UI control in WPF platform. Within the generic file i have used the following code snippet
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:WpfCustomControlLibrary1">
<ContextMenu x:Key="ContextMenuStyle">
<MenuItem x:Name="Cut" Header="Cut">
</MenuItem>
</ContextMenu>
<Style TargetType="{x:Type local:CustomControl1}">
<Setter Property="ContextMenu" Value="{StaticResource ContextMenuStyle}"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type local:CustomControl1}">
<Border Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}">
<Button x:Name="button">
</Button>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
When i am running this code snippet in 3.5 framework i am getting System.Windows.Markup.XamlParseException Additional information: 'Cut' value cannot be assigned to property 'Name' of object 'System.Windows.Controls.MenuItem'. Names not supported under
ResourceDictionary scope. But i am not getting any exception while running in other framework. Is there any solution to resolve this problem?