I try to get the attribute values of an element, where the cursor is located like Tag
, MouseLeftButtonDown
or x:Name
and so on. The Event
is always raised, when F10 is pressed using CommandBindings:
XAML:
<Window.CommandBindings>
<CommandBinding Command="Open" Executed="Executesd"/>
</Window.CommandBindings>
<Window.InputBindings>
<KeyBinding Key="F10" Command="Open"/>
</Window.InputBindings>
Code:
private void Executesd(object sender, ExecutedRoutedEventArgs e)
{
Point mo = Mouse.GetPosition(Window);
var TagName = Mouse.DirectlyOver;
MessageBox.Show("Mouselogic Open-Commands: " + mo.ToString() + " -> " + TagName);
}
With DirectlyOver
I only can get the Control.Element
. Thats not exactly what I am looking for.
<TextBlock MouseLeftButtonDown="MaximizeToolbar" Tag="FolderNameOrWhatever">Test</TextBlock>
I'm not using Windows.Forms. With Tag="FolderNameOrWhatever"
I want to handle an action. I also need the parents Tag
, when there is no Tag
in the child located.
I ve found nothing with google that fits my problem, getting the elements attributsname an values where my cursor is located.
May someone can help? I'm new at C#. In JS I could solve it, but C# is very different.