Reputation: 303
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="?" />
Upvotes: 30
Views: 39077
Reputation: 7765
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
Upvotes: 13