Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do you show a StackPanel with 3 Buttons, when the mouse is over the parent control?
    text
    copied!<p>The XAML below has a Rectangle and a StackPanel with 3 Buttons. It shows the StackPanel when the mouse pointer is moved over the MyRect Rectangle. </p> <p><strong>BUT</strong> it flickers like crazy when the mouse pointer is moved over one of the Button controls inside the StackPanel. This is because the mouse pointer is no longer over the MyRect Rectangle. So it sets the StackPanel Visibility to Collapsed. And that causes the mouse pointer to be over the MyRect Rectangle again, which causes the StackPanel Visibility to be Collapsed. This continues round and round causing the Flicker.</p> <p>What do I need to do to display the StackPanel and allow the user to move their mouse pointer over the buttons (and/or any contents) of the StackPanel without it flickering?</p> <p>And I'm looking to do it all in XAML. (No code behind please).</p> <pre><code>&lt;Grid Margin="50"&gt; &lt;Grid.RowDefinitions&gt; &lt;RowDefinition Height="50" /&gt; &lt;RowDefinition Height="100" /&gt; &lt;/Grid.RowDefinitions&gt; &lt;Rectangle x:Name="MyRect" Fill="Yellow" Grid.RowSpan="2"/&gt; &lt;StackPanel Orientation="Horizontal"&gt; &lt;StackPanel.Style&gt; &lt;Style&gt; &lt;Setter Property="StackPanel.Visibility" Value="Collapsed"&gt;&lt;/Setter&gt; &lt;Style.Triggers&gt; &lt;DataTrigger Binding="{Binding ElementName=MyRect, Path=IsMouseOver}" Value="true"&gt; &lt;Setter Property="StackPanel.Visibility" Value="Visible"&gt;&lt;/Setter&gt; &lt;/DataTrigger&gt; &lt;/Style.Triggers&gt; &lt;/Style&gt; &lt;/StackPanel.Style&gt; &lt;Button Margin="10" Width="65"&gt;One&lt;/Button&gt; &lt;Button Margin="10" Width="65"&gt;Two&lt;/Button&gt; &lt;Button Margin="10" Width="65"&gt;Three&lt;/Button&gt; &lt;/StackPanel&gt; &lt;/Grid&gt; </code></pre>
 

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