Note that there are some explanatory texts on larger screens.

plurals
  1. POOverlay 2 controls and toggle which one is visible using WPF
    primarykey
    data
    text
    <p>This is a general question which will apply to any WPF control.</p> <p>What I am trying to do is place two controls on top of each other and toggle which is visible.</p> <p>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.</p> <p>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.</p> <p>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.</p> <pre><code>&lt;Grid&gt; &lt;Button Visibility="{Binding ShowAboutBox, Converter={StaticResource BoolToVisConverter}}"&gt; &lt;Button.Content&gt;About My App&lt;/Button.Content&gt;&lt;/Button&gt; &lt;DockPanel Canvas.ZIndex="0" LastChildFill="True"&gt;&lt;/DockPanel&gt; &lt;/Grid&gt; </code></pre> <p>I'm not that experienced in WPF but assuming that this should be quite easy - any suggestions?</p> <p>EDIT:</p> <p>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.</p> <pre><code>&lt;Grid&gt; &lt;Button Visibility="{Binding ShowAboutBox, Converter={StaticResource BoolToVisConverter}}"&gt; &lt;Button.Content&gt;About My App&lt;/Button.Content&gt;&lt;/Button&gt; &lt;DockPanel&gt;&lt;/DockPanel&gt; &lt;/Grid&gt; </code></pre> <p>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).</p> <p>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.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload