Reputation: 415
When I change my canvas width on runtime, can I get an Event when the width of my canvas change ?
Changing my width on runtime trough:
myCanvas.width = myCanvas.width + 1;
Is there an event like:
private void CanvasWidthChanged(object sender, WidthChangedEventArgs e)
{
}
Upvotes: 1
Views: 3259
Reputation: 2520
You can create own class inherited from Canvas and proces changed of size in this class. Something like
public class DXFCanvas : Canvas
{
protected override void OnRenderSizeChanged(SizeChangedInfo sizeInfo)
{
base.OnRenderSizeChanged(sizeInfo);
// Your action ...
// (SizeChangedInfo contains old and new size)
}
}
Upvotes: 0
Reputation: 4097
Use the SizeChanged Event.
myCanvas.SizeChanged += myCanvas_SizeChanged;
private void myCanvas_SizeChanged(object sender, SizeChangedEventArgs e)
{
}
Upvotes: 4
Reputation: 17973
You should be able to use the SizeChanged event.
There's a WidthChanged property in the event args that you can use to see if the width changed.
Upvotes: 3