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 6128463
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T16:37:47+00:00 2026-05-23T16:37:47+00:00

This is a general question which will apply to any WPF control. What I

  • 0

This is a general question which will apply to any WPF control.

What I am trying to do is place two controls on top of each other and toggle which is visible.

I.e I want to control the visbility of them such that only one control is visible at one time.
One control will normally be hidden but upon some event will be displayed on top of the other control.

I have tried changing the z order and tried using the visibility property, but while I can make the normally hidden control appear, the normally displayed control is also visible.

E.g. the button below is normally hidden, but upon an a menu item click, for example, the ShowAboutBox property in a viewmodel will be set, changing the visibility property. At which point the button should be visible and not the dockpanel.

<Grid>
    <Button Visibility="{Binding ShowAboutBox, Converter={StaticResource BoolToVisConverter}}">
        <Button.Content>About My App</Button.Content></Button>
    <DockPanel Canvas.ZIndex="0"  LastChildFill="True"></DockPanel>
</Grid>

I’m not that experienced in WPF but assuming that this should be quite easy – any suggestions?

EDIT:

The code above shows a mix of techniques I tried. And probably confuses the issue. Most recently I have tried the following to no avail either.

<Grid>
    <Button Visibility="{Binding ShowAboutBox, Converter={StaticResource BoolToVisConverter}}">
        <Button.Content>About My App</Button.Content></Button>
    <DockPanel></DockPanel>
</Grid>

Changing the visibility of the button causes it to display, but the dock panel and its contents are still visbile on top of the button. (the button is shown behind the dockpanel due to the z order).

I guess I could toggle the visibility of the dock panel at the same time (to be the reverse of the button) but I was hoping to avoid that.

  • 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-05-23T16:37:48+00:00Added an answer on May 23, 2026 at 4:37 pm

    I would bind the DockPanel’s Visibility to ShowAboutBox as well, but using an inverse converter. I have a bunch of handy little converters like this created for just this type of scenario:

    <Grid>
        <Button Visibility="{Binding ShowAboutBox, Converter={StaticResource BoolToVisConverter}}">About My App</Button>
        <DockPanel Visibility="{Binding ShowAboutBox, Converter={StaticResource BoolToInverseVisConverter}}"></DockPanel>
    </Grid>
    

    And the basic converter (could be expanded to support nullables, etc):

    public class BooleanToInverseVisibilityConverter : IValueConverter {
    
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture) {
            return (bool) value ? Visibility.Collapsed : Visibility.Visible;
        }
    
        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) {
            return null;
        }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is a general question, so I won't name which site's API I am
This question is meant to apply to interfaces in general, but I'll use AS3/Flex
I have 3 user controls, each one of which will need to pull data
This is a two part question: General, and Specific. For the general: I often
I have a more general question but any advice in implementing this in C#
Yesterday I asked this general question about decimals and their internal precisions. Here is
This is a general question about MVC as a pattern, but in this case
This is a general question concerning technology decisions for a product development. My aim
This is a general question. And may not be specific to datagrids. How can
This is a general question about character encoding when using MD5 libraries in various

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.