Hi, I am trying to install MenuItem.Icon through a style installer:
<Style x:Key="MenuItem_Delete" TargetType="MenuItem" BasedOn="{StaticResource {x:Type MenuItem}}"> <Setter Property="Header" Value="_Delete"/> <Setter Property="MenuItem.Icon"> <Setter.Value> <Image Source="Resources/Delete.png"/> </Setter.Value> </Setter> </Style>
At runtime, I get the following exception: Unable to add contents of type "System.Windows.Controls.Image" to an object of type "System.Object". Error in object 'System.Windows.Controls.Image' in markup file 'WpfApplication1; component / application.xaml 'Line 164 Position 26.
On the other hand, this is an example in the link above:
<MenuItem Header="New"> <MenuItem.Icon> <Image Source="data/cat.png"/> </MenuItem.Icon> </MenuItem>
Thanks.
wpf xaml icons contextmenu menuitem
Shimmy
source share