I have a custom WPF control that has a XAML Control template applied to it.
The XAML Control template has an image whos width and height I want to bind to a property in my control class.
<Image Height="24" Width="24" Source="{Binding Path=IconSource}" Margin="2" />
I want to bind the Height and Width to a property of my class similar to how I am binding the onclick event of a button I have like so:
MyClass Code
#region Constructor
public MyClass()
{
CommandBindings.Add(new CommandBinding(ButtonClickCommand, ButtonClickCommand_Executed));
}
#endregion
#region Public
public static readonly RoutedUICommand ButtonClickCommand= new RoutedUICommand();
#endregion
private void ChangeViewCommand_Executed(object sender, ExecutedRoutedEventArgs e)
{
//do something
}
XAML
<Button Name="MyButton" Command="{x:Static local:MyClass.ButtonClickCommand}">
<Image Source="{DynamicResource MyImage}" Width="20" Height="20"/>
</Button>
How do I do something similar for the Image Height and Width?? I will have a property that I want to modify and have this reflected in the XAML.