Freelance Project Requests info@CodeDocu.de Software Development in C# WPF Asp.Net Core Vba Excel Word SQL-Server EF Linq, UWP Net
#

 

 

 

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

 

Solution:

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;

 

 

 

 

Solution:

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"

        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"

        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"

        xmlns:local="clr-namespace:Schichtplaner"

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

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

        WindowStyle="ToolWindow" 

        >

 

Mobile
»
WPF: Explorer with path open
»
WPF: Open a Window at a position
»
WPF: Selection enter open and well take over with Button Elements
»
WPF: Select Folder with Startup Directory
»
WPF: FolderDialog and GetFiles
»
Error CS0234: The type or namespace name Forms does not exist in the namespace
»
WPF: Filedialog, OpenFileDialog

.

Contact for Jobs, Project Requests: raimund.popp@microsoft-programmierer.de