Can I know how to add an event when I click on a TextBlock? I can't find the onClick on the TextBlock. Does anyone know what is the name of the event?
code:
<TextBlock Name="Title" Click="?" />
Just use the "PreviewMouseDown" event. Good luck!
You can use an InputBinding
:
<TextBlock Text="{Binding SomeText}">
<TextBlock.InputBindings>
<MouseBinding Command="{Binding SomeCommand}" MouseAction="LeftClick" />
</TextBlock.InputBindings>
</TextBlock>
Source: https://learn.microsoft.com/en-us/dotnet/api/system.windows.input.inputbinding
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With