Search code examples
c#wpfxamlbuttonvisual-studio-2017

Hide Button but keep function - XAML


First I've tried to implement a Click Event to my Textbox. Unfortunately, it doesn't work with XAML. So, my plan is to add a Button and whenever you click this Button, the textfield below should change it's letter (back to 1). My idea was to put the button over the first textbox and to hide it, so that you see the first textbox.

But, if I set the button as hidden, my function doesn't work anymore. Is there a solution to hide the button, but, still keep the function for the second textbox?


Solution

  • Hidden means control is loaded, takes up space on the screen, but won't be operational(clickable), so it doesn't help you.

    You could edit the button's ControlTemplate and make it a simple Grid with Transparent background, without the Hidden part of course.

    And last thing, you could add MouseDown function on your TextBox so you won't need the button at all.