N7_2014
N7_2014

Reputation: 1

Prevent flickering when changing "Left" property in OnRenderSizeChanged

I have a main window where I want the "anchor" to be the right so that the window will expand to the left when the width changes. I did this by overriding the OnRenderSizeChanged event like so:

protected override void OnRenderSizeChanged(SizeChangedInfo sizeInfo)
{
    var vm = DataContext as MainViewModel;

    var widthDif = sizeInfo.NewSize.Width - sizeInfo.PreviousSize.Width;
    Left -= widthDif;
 }

The problem with this approach is that there is a flickering effect when this occurs as you see the window move to the left. Any ideas on how to fix this? Thanks.

Upvotes: 0

Views: 128

Answers (1)

Robert J.
Robert J.

Reputation: 2701

Interesting...Have you tried setting UseLayoutRounding=True ?

Upvotes: 0

Related Questions