Is there a way to set the Icon for XamMenuItem in App.Xaml?
HI,
Please let me know if you need further assistance regarding this issue.
Sincerely,
Matt
Developer Support Engineer
Setting Image in Style is not good idea and it won’t work. The Image object is created only once when the style is put together during Xaml parsing. The important thing about UIElements (like Image) is that a single instance can only appear once in the Visual Tree. Because of that it cannot appear in every XamMenuItem.
Possible alternative for you is to create new ContentTemplate of the XamMenuItem and apply it.
Matt Developer Support Engineer
Thanks for the response. I'm sorry I should've clarified. I meant as a style.
This setter for the icon doesn't work.
<Style TargetType="ig:XamMenuItem" x:Key="innerButtonsMenuItem"> <Setter Property="Header" Value="Help"/> <Setter Property="Margin" Value="-2,-2,0,0"/> <Setter Property="Height" Value="20"/> <Setter Property="Icon"> <Setter.Value> <Image Source="{StaticResource iconHelp}"/> <!--<Image Source="Assets/iconHelp.png"/>--> <!--<Image Source="/MyTest;component/Assets/iconHelp.png"/>--> <!--<ImageBrush ImageSource="Assets/iconHelp.png" Stretch="None" AlignmentX="Center" AlignmentY="Center"/>--> </Setter.Value> </Setter> </Style>
You could define a BitMapImage in your Application Resources, then bind to it.
Here is the code snippets:
<BitmapImage x:Key="opdb" UriSource="Images/OpenPDB.png"/>
<ig:XamMenuItem >
<ig:XamMenuItem.Icon>
<Image Source="{StaticResource opdb}"/>
</ig:XamMenuItem.Icon>
Sincerely, Matt