Articles in categories

Now on Amazon

WPF clickable TextBlock

In Winforms you have the LinkLabel control, but not in WPF.
Here are two ways of creating something similar.

TextBlock with InputBinding

<TextBlock Text="Forgot your password?"
		 Margin="5">
	<TextBlock.InputBindings>
			<MouseBinding Command="{Binding DoSomethingCommand}"
						MouseAction="LeftClick" />
	</TextBlock.InputBindings>
</TextBlock>

 

TextBlock with Hyperlink

<TextBlock >
  <Hyperlink Command="{Binding ShowForgotPasswordExpanderCommand}">Forgot your password?</Hyperlink>
</TextBlock>