I have a WP7 app where I would like to have a "clickable" TextBlock
area, that when a user clicks on the TextBlock
, it puts it into edit mode (a different control).
This would add another explicit step for a user before editing text.
There is no click event for the TextBlock
(which doesn't surprise me).
Is there any way to do this? Wrapped in another control, or something similar?
Yes, there is a click event. Its called MouseLeftButtonDown
textBlock1.MouseLeftButtonDown +=new MouseButtonEventHandler(textBlock1_MouseLeftButtonDown);
private void textBlock1_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
}
I have solved this by creating a Button with the TextBlock inside its Template like this:
<Button Click="button_Click">
<Button.Template>
<ControlTemplate>
<TextBlock ... />
</ControlTemplate>
</Button.Template>
</Button>
It's a bit more markup, but you don't need to write any code, it is provided by the framework and works properly.
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