Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I think you want to set your UserControl's ControlTemplate with a ContentPresenter located inside (so you can define where the Content will be presented).</p> <p>Your Custom UserControl:</p> <pre><code>&lt;UserControl x:Class="TestApp11.UserControl1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"&gt; &lt;UserControl.Template&gt; &lt;ControlTemplate&gt; &lt;StackPanel&gt; &lt;TextBlock Text="Custom Control Text Area 1" /&gt; &lt;ContentPresenter Content="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Content}" /&gt; &lt;TextBlock Text="Custom Control Text Area 2" /&gt; &lt;/StackPanel&gt; &lt;/ControlTemplate&gt; &lt;/UserControl.Template&gt; &lt;/UserControl&gt; </code></pre> <p>Usage:</p> <pre><code>&lt;Window x:Class="TestApp11.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:l="clr-namespace:TestApp11" Title="Window1" Height="250" Width="200"&gt; &lt;StackPanel&gt; &lt;l:UserControl1&gt; &lt;Button Content="My Control's Content" /&gt; &lt;/l:UserControl1&gt; &lt;/StackPanel&gt; &lt;/Window&gt; </code></pre> <p><img src="https://i.stack.imgur.com/JeCgc.png" alt="enter image description here"></p> <p>If you need multiple items in your content section, simply place them in a container like a grid or a stackpanel:</p> <pre><code>&lt;l:UserControl1&gt; &lt;StackPanel&gt; &lt;Button Content="Button 1" /&gt; &lt;Button Content="Button 2" /&gt; &lt;/StackPanel&gt; &lt;/l:UserControl1&gt; </code></pre>
    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. 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