Results 1 to 3 of 3

Thread: Grid Control Question

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jun 2008
    Posts
    159

    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!

  2. #2
    Lively Member
    Join Date
    Jul 2007
    Posts
    127

    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.

  3. #3
    Frenzied Member
    Join Date
    Jul 2008
    Location
    Rep of Ireland
    Posts
    1,380

    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
  •  



Click Here to Expand Forum to Full Width