Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing the start up location of a WPF window in XAML to Bottom-Right

Tags:

c#

wpf

xaml

Is it possible to set the manual startup location for a WPF window in XAML to start in the Bottom-Right corner of the screen? I can do it in code-behind, but when the window opens, it pops up at the manual location (middle-left of the screen) then it jumps to the bottom right of the screen and it does not look very good.

I can set the location in the Top-Left of the corner in XAML with this coding:

<Window x:Class="WpfApplication1.Window1" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    Title="Window1" 
    Height="500" Width="500"
    WindowStartupLocation="Manual" 
    Left="0" Top="0">
</Window>

Can I do the same for the Bottom-Right corner of the screen with XAML coding to fit ANY screen size?

like image 905
CareTaker22 Avatar asked Oct 25 '25 07:10

CareTaker22


1 Answers

I think it is not possible to set it via xaml. But, You can set it even before the window got loaded that wont jumps from manual location.

public MainWindow()
{
    InitializeComponent();
    Left = System.Windows.SystemParameters.WorkArea.Width - Width;
    Top = System.Windows.SystemParameters.WorkArea.Height - Height;
}
like image 101
Gopichandar Avatar answered Oct 27 '25 19:10

Gopichandar



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!