Reputation: 112
When we change screen resolution the WPF window not showing on proper location(Bottom Right).
1.Change screen resolution from high to lower value. 2.Open the WPF window. 3.Again change screen resolution from low to high.
The window will not display on proper location it is going Up . I want it to again at bottom right. How can I fix this problem?
Upvotes: 2
Views: 2202
Reputation: 8104
You will have to move the window after resolution change using your own code I believe, something like this:
window.Left = SystemParameters.PrimaryScreenWidth - window.Width;
window.Top = = SystemParameters.PrimaryScreenHeight - window.Height;
Check this post to see, how to detect screen resolution change
So the whole code would be like this:
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
SystemEvents.DisplaySettingsChanged += SystemEvents_DisplaySettingsChanged;
}
void SystemEvents_DisplaySettingsChanged(object sender, EventArgs e)
{
this.Left = SystemParameters.PrimaryScreenWidth - this.Width;
this.Top = SystemParameters.PrimaryScreenHeight - this.Height;
}
}
Upvotes: 2