Skip to content

Plus Edition. Incorrect window position restoration after returning from the maximized state. #1804

Open

Description

@Alex564Alex

Sequence of actions:

  1. Child window. Left > 0 and Top > 0.
  2. Maximize the window to full screen.
  3. Restore the window position to the previous state.
    Left = 0 and Top = 0. That is, the previous position is not restored.

Source code:

        private void Child_MaximizedChanged(object sender, EventArgs e) {
		...
                WindowContainerChildData initialData = (WindowContainerChildData)windowControl.InitialData;
                windowControl.Left = initialData.Left;
                windowControl.Top = initialData.Top;
                windowControl.Width = initialData.Width;
                windowControl.Height = initialData.Height;
                windowControl.UpdateLayout();
                windowControl.Left = this.GetRestrictedLeft(windowControl);
                windowControl.Top = this.GetRestrictedTop(windowControl);
            }
        }

Corrected code:

        private void Child_MaximizedChanged(object sender, EventArgs e) {
		...
                WindowContainerChildData initialData = (WindowContainerChildData)windowControl.InitialData;
                windowControl.Width = initialData.Width;
                windowControl.Height = initialData.Height;
                windowControl.UpdateLayout();
                windowControl.Left = initialData.Left;
                windowControl.Top = initialData.Top;
                windowControl.Left = this.GetRestrictedLeft(windowControl);
                windowControl.Top = this.GetRestrictedTop(windowControl);
            }
        }

Activity

  1. changed the title [-]Plus. Incorrect window position restoration after returning from the maximized state.[/-] [+]Plus Edition. Incorrect window position restoration after returning from the maximized state.[/+] on Sep 5, 2025
  2. XceedBoucherS commented on Sep 8, 2025

    @XceedBoucherS
    Collaborator

    Hello,

    When using your initial code, yes, I can reproduce the issue.
    But if I use the latest version of Toolkit Plus, after the Maximize-Restore, the ChildWindow is back at its expected position.
    Can you confirm ?
    Here's my code to test :
    <StackPanel> <xctk:WindowContainer x:Name="_windowContainer" ModalBackgroundBrush="#80000000" Width="500" Height="500"> </xctk:WindowContainer> <Button Content="Add ChildWindow" Click="Button_AddChildWindow" /> </StackPanel>

    `private void Button_AddChildWindow( object sender, RoutedEventArgs e )
    {
    var childWindow = new ChildWindow()
    {
    Caption = "Modal Child Window",
    IsModal = true,
    Width = 150,
    Height = 150,
    Left = 30,
    Top = 30,
    WindowState = Xceed.Wpf.Toolkit.WindowState.Open,
    Content = new TextBlock() { Text = "WindowContent" }
    };

    _windowContainer.Children.Add( childWindow );
    }`

    Action:
    -Press the Button
    -Move the ChildWindow to center
    -Maximize the ChildWindow
    -Restore the ChildWindow
    -Result : ChildWindow is back to center

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions