How do I add my property called weight to an image and use it like this:?
myImage.weight
(assuming i have already defined myImage in XAML)
here's my code:
public partial class MainWindow : Window
{
public double Weight
{
get
{
return (double)GetValue(WeightProperty);
}
set
{
SetValue(WeightProperty, value);
}
}
public static readonly DependencyProperty WeightProperty = DependencyProperty.Register("Weight", typeof(Double), typeof(Image));
public MainWindow()
{
this.InitializeComponent();
myImage.Weight = 2;'
here the last line doesn't work because the property Weight does not attach to myImage.
This below also doesn't work in XAML:
<Image x:Name="myImage" Weight="2" />