I have a board of rectangles which I want to scale dynamically. I can set the Height and Width properties of the rectangle element. The only property that doesn't cooperate is the margin..
I tried binding the same property margin in my ViewModel to either width, height and margin and it only works well with the width and height. As soon as I try it on the margin property of the rectangle it takes a lot of time to load the window AND it eventually shows up with no margin at all..
Does anyone know why this is happening?
Rectangle:
<Rectangle Margin="{Binding ElementName=root, Path=DataContext.Margin}" Fill="White" Height="{Binding ElementName=root, Path=DataContext.Margin}" Width="{Binding ElementName=root, Path=DataContext.Margin}"></Rectangle>
Property:
private int _margin = 5;
public int Margin
{
get
{
return _margin;
}
}