私は UserControl を拡張する MyUserControl クラスをパラメータで持っています:
namespace MyNameSpace
{
public partial class MyUserControl: UserControl
{
public MyUserControl()
{
InitializeComponent();
}
private Control _owner;
public Control Owner
{
set { _owner = value; }
get { return _owner; }
}
}
}
たとえば、XAML 内の Grid をそのパラメーターとして渡すにはどうすればよいですか?
<Window x:Class="MyNameSpace.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525"
xmlns:my="clr-namespace:MyNameSpace">
<Grid x:Name="grid1">
<my:MyUserControl x:Name="myUserControl1" Parent="*grid1?*" />
</Grid>
</Window>