How to make TextBlock clickable. It is necessary to comply with the mvvm concept, in the bind to the method or command in the ViewModel

 public ICommand RememberMeCommand { get { rememberMeChecked = !_rememberMe; return null; } set { rememberMeChecked = !_rememberMe; } } 

I register a bandage here, but it does not even enter when pressed, there is no entry to the debugger point. How to implement?

  • Give the code text, not a picture. Why do you think get { return null; } should work fine? - Andrey NOP
  • I don’t think that the problem should work, that stupidly not to enter when the debugger is pressed, the command stupidly doesn’t see it, but don’t click on the texblock - j.doe
  • Drive on the text block and tie the command to the usual button, how to make it work - replace the button with the text block as I have in response. All the rest is not in substance. I answered the question. - Andrey NOP
  • I have a second option. I have this textblock to beat the content of the check box, but if you shove it like content, the checkbox itself is constantly placed in the center, overriding the text and doesn’t want to put it on the left - j.doe
  • How does this relate to the current question? If you have another question - ask it separately. - Andrey NOP

1 answer 1

For example:

 <Button Command="{Binding ClickCommand}"> <Button.Template> <ControlTemplate TargetType="Button"> <TextBlock Text="Some text"/> </ControlTemplate> </Button.Template> </Button> 

Or so:

 <TextBlock Text="Some text"> <TextBlock.InputBindings> <MouseBinding Gesture="LeftClick" Command="{Binding ClickCommand}"/> </TextBlock.InputBindings> </TextBlock> 
  • Already tried, even through the trigger, nothing happens By debugger not even enter the team - j.doe
  • I personally just checked both solutions, they are both workers. You are doing something wrong, perhaps the property for the binding is not located. Check for binding errors. - Andrey NOP
  • I updated the question, the first time I work with wpf somewhere I mess like - j.doe