Ashish Goyal

Ashish Goyal

  • NA
  • 5
  • 5.3k

How do I bind a canvas to a button in wpf. Like clicking button should alter canvas props.

Jul 13 2012 8:14 AM
How do I bind a particular canvas to a button in wpf. Like clicking button should alter canvas props like changing its visibility and all. The problem is that I don't wanna hide/unhide on mouse click event. It should be like canvas changing its property automatically on the mouse click of its button.

The situation is as follows :

I have say 10 buttons and 10 canvas.
On click of button 1, canvas 1 should be visible and others collapsed
On click of button 2, canvas 2 should be visible and others collapsed
On click of button 3, canvas 3 should be visible and others collapsed

.. for all the buttons...

If I write this code in C# seperately toggling between the visibility of all the canvas, then its gonna be a poor code.. Isn't there some way to do it in xaml using bindings, or triggers, or even custom controls.