SilverFlow.Controls.FloatingWindow.ContentRoot_SizeChanged C# (CSharp) Method

ContentRoot_SizeChanged() private method

Handles the SizeChanged event of the ContentRoot control to update window position only once when the window is opened.
private ContentRoot_SizeChanged ( object sender, System.Windows.SizeChangedEventArgs e ) : void
sender object The source of the event.
e System.Windows.SizeChangedEventArgs The instance containing the event data.
return void
        private void ContentRoot_SizeChanged(object sender, SizeChangedEventArgs e)
        {
            contentRoot.SizeChanged -= new SizeChangedEventHandler(ContentRoot_SizeChanged);
            double dx = -(e.NewSize.Width.ValueOrZero() - e.PreviousSize.Width.ValueOrZero()) / 2;
            double dy = -(e.NewSize.Height.ValueOrZero() - e.PreviousSize.Height.ValueOrZero()) / 2;
            Point point = Position.Add(dx, dy);
            MoveWindow(point);
        }
FloatingWindow