Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Here's what I would do, first I would separate my reusable parts into resources, and reference them using <code>ContentControls</code> in XAML. This applies to the <code>Popup</code> as well as to the <code>Button</code>. However I don't wish to restrict myself to having only a button, so I'll use a <code>ContentControl</code> as well for that:</p> <p>The Popup template:</p> <pre><code>&lt;ControlTemplate x:Key="PopupTemplate"&gt; &lt;Border Background="White" BorderBrush="Black" Padding="5" BorderThickness="2" CornerRadius="5"&gt; &lt;StackPanel Orientation="Vertical"&gt; &lt;Button Command="{Binding MyCommand}" CommandParameter="5"&gt;5&lt;/Button&gt; &lt;Button Command="{Binding MyCommand}" CommandParameter="10"&gt;10&lt;/Button&gt; &lt;Button Command="{Binding MyCommand}" CommandParameter="15"&gt;15&lt;/Button&gt; &lt;Button Command="{Binding MyCommand}" CommandParameter="20"&gt;20&lt;/Button&gt; &lt;/StackPanel&gt; &lt;/Border&gt; &lt;/ControlTemplate&gt; </code></pre> <p>The <code>ContentControl</code> template:</p> <pre><code>&lt;ControlTemplate x:Key="MyControlTemplate" TargetType="ContentControl"&gt; &lt;Grid Name="MyControl"&gt; &lt;ContentPresenter Content="{TemplateBinding Content}"/&gt; &lt;Popup Name="MyPopup" StaysOpen="True" Placement="Bottom"&gt; &lt;ContentControl Template="{StaticResource PopupTemplate}"/&gt; &lt;/Popup&gt; &lt;/Grid&gt; &lt;ControlTemplate.Triggers&gt; &lt;Trigger SourceName="MyControl" Property="UIElement.IsMouseOver" Value="True"&gt; &lt;Setter TargetName="MyPopup" Property="Popup.IsOpen" Value="True"/&gt; &lt;/Trigger&gt; &lt;/ControlTemplate.Triggers&gt; &lt;/ControlTemplate&gt; </code></pre> <p>Now in the main window XAML, I would create the following:</p> <pre><code>&lt;ContentControl Template="{StaticResource MyControlTemplate}"&gt; &lt;Button Content="Test"/&gt; &lt;/ContentControl&gt; </code></pre> <p>If you have any questions, I'll be happy to answer.</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.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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