Reputation: 145
I have style for MenuItem:
<Style x:Key="mainMenuItem"
TargetType="{x:Type Resources:MainMenuItem}">
</Style>
How can I set TemplateBinding ImageSource for the Icon Property? I have MainMenuItem.cs:
public class MainMenuItem : MenuItem
{
public static readonly DependencyProperty ImageSourceProperty =
DependencyProperty.Register(
"ImageSource",
typeof (ImageSource),
typeof (MainMenuItem),
new UIPropertyMetadata(null));
public ImageSource ImageSource
{
get { return (ImageSource) GetValue(ImageSourceProperty); }
set { SetValue(ImageSourceProperty, value); }
}
}
Upvotes: 0
Views: 472
Reputation: 184296
You could just completely ignore the Icon
property and create a Setter
for the Template
in which you define an Image
in the front which has a template binding to ImageSource
, or you could register a dependency property changed callback on the ImageSource
in which you create an Image
and set it as the Icon
.
Upvotes: 1