Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8345801
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T06:48:10+00:00 2026-06-09T06:48:10+00:00

The WPF application I’ve created contains a Grid with 3 rows. I have a

  • 0

The WPF application I’ve created contains a Grid with 3 rows. I have a set of buttons in the 3rd row. On Clicking the Buttons, the forms are displayed in the 2nd row of the Grid. However What I’ve done is quite messy because I’ve created all the form contents in the same window and have set the visibility to Hidden.

sample code:

<Grid Name="panel1" Grid.Row="1" Visibility="Hidden">
 //contains a lot of textblocks,buttons and images
</Grid>
<Grid Name="panel2" Grid.Row="1" Visibility="Hidden">
 //contains a lot of textblocks,buttons and images
</Grid>
 <Grid Name="panel3" Grid.Row="1" Visibility="Hidden">
 //contains a lot of textblocks,buttons and images
</Grid>

My xaml Code looks like this:

private void Image_MouseLeftButtonDown_1(object sender, System.Windows.Input.MouseButtonEventArgs e)
    {
        panel1.Visibility = System.Windows.Visibility.Hidden;
        panel2.Visibility = System.Windows.Visibility.Visible;
        panel3.Visibility = System.Windows.Visibility.Hidden;
    }

This approach looks really messy as I’ve included all the code in the Main Xaml file.
Need some alternate ways to do this. Kindly help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T06:48:11+00:00Added an answer on June 9, 2026 at 6:48 am

    Create a method like this

    private void VisibilityManager(Grid grd)
    {
        new List<Grid>(){ panel1, panel2, panel3}
           .ForEach(x => x.Visibility = Visibility.Hidden);
        grd.Visibility = Visibility.Visible;
    }
    

    and call it like this

    VisibilityManager(panel1);
    

    for making panel1 visible and all other hidden.

    In future if you have to increase your grids just make changes inside this method.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My WPF application is becoming a real pain. I have created a Window and
I created a wpf application which have a single window which is getting started
I have created a WPF application and deployed it to a location on my
I have a WPF application that uses 3rd party controls (like http://navigationpane.codeplex.com ) which
I have a WPF application which connects to a remote database over internet and
I have a WPF application, where as part of the startup, I need to
I have a wpf application that is leaking memory...is there a way to detect
I have a WPF application, after closing the app its process app.exe *32 is
I have a wpf application using Caliburn.Micro. I need to bind a ListBox to
I have a WPF application where I'm trying to create a diagnostics panel that's

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.