|
-
Mar 12th, 2010, 11:54 AM
#1
Thread Starter
Addicted Member
Grid Control Question
Hello,
I am trying to find (or understand) the best way to control a grids Visibility property. Here is my example. Let's say I have 16 Grid views, and 16 buttons, each button should make an associated Grid view 'Visible'. Now, when I do this it should make the remaining 15 Grids 'Hidden'.
I know I can do a GridName.Visibility = Visibility.Hidden for all 15 and then a .Visible for the one, but doing this in 16 places seems really redundant (or annoying). Is there a better way to contro this???
Thanks in advance!
-
Mar 15th, 2010, 09:11 AM
#2
Lively Member
Re: Grid Control Question
you could use the same click event for all the buttons and determine which button was clicked and then loop thru all the grid views and figure out which one is associated with that button, then make it visible. then you will only have to do visibility = Visible once instead 16 times for each buttons click event.
-
Apr 16th, 2010, 04:31 PM
#3
Frenzied Member
Re: Grid Control Question
Easier again is to set the visibility of the button or even the opacity. You can do so by writing a single trigger and then binding it to all of your buttons in Xaml, no code needed:
http://www.wpfdude.com/articles/Triggers.aspx
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|