Readdy Write  
0,00 €
Your View Money
Views: Count
Self 20% 0
Your Content 60% 0

Users by Links 0
u1*(Content+Views) 10% 0
Follow-Follower 0
s2*(Income) 5% 0

Followers 0
Login Register as User

WPF: Open Window at an position

13.01.2019 (πŸ‘1460)



How do you set a WPF Window so that it is placed directly at the position or place of the mouse when opening?



To do this directly in the event Window _ Loaded adjust the top and left position


    this.Top = Mouse.GetPosition(null).Y;

    this.Left = Mouse.GetPosition(null).X;






In the window, which is opened, you have to use the. Top and. Left property to put the value of the mouse position


private void Window_Loaded(object sender, RoutedEventArgs e)


    //----< Window_Loaded () >--------


    //< Window_Position >

    //*TopLeft-Corner to Mouse-Position

    this.Top = Mouse.GetPosition(null).Y;

    this.Left = Mouse.GetPosition(null).X;

    //</ Window_Position >

    //----</ Window_Loaded () >--------





Activate Event in xaml of Windows Following


WindowStartupLocation="Manual"  Loaded="Window_Loaded" 



Xaml of the window


<Window x:Class="Schichtplaner.PU_Schichtplan_Mitarbeiter"






        mc:Ignorable="d" FontSize="12pt"

        Title="Mitarbeiter wΓ€hlen" Height="450" Width="400" WindowStartupLocation="Manual"  Loaded="Window_Loaded"