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;



WPF: Open a Window at a position




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

WPF: Open a Window at a 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" 




Software Entwicklung Stuttgart NĂ¼rtingen
Suche Projekte C#, WPF, Windows App,ASP.Net, vb.Net, WinForms, SQL Server, Access, Excel