Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>It appears to me that your are just wondering how to use a custom control in multiple places.</p> <p>I've created a custom control (MyCustomControl) that has the StackPanel shown in your code, then used it multiple times on the MainPage.</p> <p><strong>MyCustomControl.xaml</strong></p> <pre><code>&lt;UserControl x:Class="SilverlightApplication2.MyCustomControl" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d"&gt; &lt;StackPanel&gt; &lt;Button Content="Button 1" Height="30" Width="200"/&gt; &lt;Button Content="Button 2" Height="30" Width="200"/&gt; &lt;/StackPanel&gt; </code></pre> <p></p> <p><strong>MyCustomControl.xaml.cs</strong></p> <pre><code>public partial class MyCustomControl : UserControl { public MyCustomControl() { InitializeComponent(); } } </code></pre> <p>Then I've used that custom control twice in the main view.</p> <p><strong>MainPage.xaml</strong></p> <pre><code>&lt;UserControl x:Class="SilverlightApplication2.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" xmlns:local="clr-namespace:SilverlightApplication2" d:DesignHeight="300" d:DesignWidth="400"&gt; &lt;StackPanel&gt; &lt;local:MyCustomControl Margin="10" HorizontalAlignment="Center" VerticalAlignment="Center"/&gt; &lt;local:MyCustomControl Margin="10" HorizontalAlignment="Center" VerticalAlignment="Center"/&gt; &lt;/StackPanel&gt; </code></pre> <p></p> <p><strong>MainPage.xaml.cs</strong></p> <pre><code>public partial class MainPage : UserControl { public MainPage() { InitializeComponent(); } } </code></pre> <p><strong>Output</strong></p> <p><img src="https://i.stack.imgur.com/uJJjE.png" alt="alt text"></p>
    singulars
    1. This table or related slice is empty.
    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. 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