I am having some issues rendering a window, I was wondering if there is a way I can set all or a subset of these properties and only redraw/render the window once.
My problem is that I am rendering 2 windows and making them “attached” so they move and resize in unison. This means that when I am resizing/moving one window, I end up making 4 calls to render when I should only need at most 2.
As an example, the “Move_Click” method is attached to a button on my window. When clicked, this ends up calling “OnRender” twice.
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
protected override void OnRender(DrawingContext drawingContext)
{
Console.Error.WriteLine("On rendering...");
base.OnRender(drawingContext);
}
private void Move_Click(object sender, RoutedEventArgs e)
{
this.Left--;
this.Top--;
this.Width--;
this.Height--;
}
}
You could just store a flag that states whether to render or not:
You could wrap it with public methods such as SuspendRender() and ResumeRender().