UserControl1.xaml
<UserControl xClass="WpfApplication1.UserControl1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlnsx="http://schemas.microsoft.com/winfx/2006/xaml"
xmlnsmc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlnsd="http://schemas.microsoft.com/expression/blend/2008"
mcIgnorable="d"
dDesignHeight="300" dDesignWidth="300">
<Grid>
<StackPanel>
<Button Content="ボタン" Click="Button_Click" />
<TextBlock Name="textBlock" />
</StackPanel>
</Grid>
</UserControl>
UserControl1.cs
using System.Windows;
using System.Windows.Controls;
namespace WpfApplication1 {
public partial class UserControl1 : UserControl {
public UserControl1() {
InitializeComponent();
}
private void Button_Click(object sender, RoutedEventArgs e) {
this.textBlock.Text = "こんにちは";
}
}
}
MainWindow.xaml
<Window xClass="WpfApplication1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlnsx="http://schemas.microsoft.com/winfx/2006/xaml"
xmlnslocal="clr-namespace:WpfApplication1"
Title="MainWindow">
<StackPanel>
<localUserControl1 />
<localUserControl1 />
</StackPanel>
</Window>
検証