Minimized window position in WPF

后端 未结 2 1294
长情又很酷
长情又很酷 2021-01-24 09:45

I am trying to save the position of a custom dialog to the users registry, so that when they reload the same dialog, it appears in the same place they moved or resized it to pre

2条回答
  •  后悔当初
    2021-01-24 10:13

    I guess you are updating the window position when the window is closed? There are a couple of solutions if that is the case.

    1) Save the window position on a different event, like when the window is resized or moved. 2) Check to see if the window is minimized before saving the X and Y positions.

    Example:

    switch (this.WindowState)
    {
        case WindowState.Maximized:
            // don't update the X,Y
            break;
        case WindowState.Minimized:
            // don't update the X,Y
            break;
        case WindowState.Normal:
            // DO update the X,Y
            break;
    }
    

提交回复
热议问题