I'm currently writing a program for drawing class diagrams, and I'm using the MVVM pattern. My classes' width and height in the user interface is set to auto, as I let the containing elements define the size.
Problem is that I need the width and the height in my model to do some calculations, so I need a reverse binding or something to update the properties in my model, which I don't know much about. How do I do this?
I tried this, but didn't work:
XAML:
Width="{Binding Width, Mode=OneWayToSource}" Height="{Binding Height,
Mode=OneWayToSource}">
C#
private int width;
public int Width {
get { return width; }
set {
width = value;
}
}
private int height;
public int Height {
get { return height; }
set {
height = value;
}
}