8,756
社区成员




public partial class UserControl1 : UserControl
{
public static DependencyProperty ISProperty = DependencyProperty.Register("IS",
typeof(string), typeof(UserControl1), new PropertyMetadata(""));
[Category("Common Properties")]
public string IS
{
get { return (string)GetValue(ISProperty); }
set { SetValue(ISProperty, value); }
}
public UserControl1()
{
InitializeComponent();
MessageBox.Show(IS);
}
}
<Grid>
<my:UserControl1 HorizontalAlignment="Left" Name="userControl11" IS="test" />
</Grid>
<UserControl x:Class="ButtonControlLibrary.MyUserControl"
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"
d:DesignHeight="300" d:DesignWidth="400">
<Button Content="{Binding IS}" Height="300" Width="300"></Button>
</UserControl>
public partial class MyUserControl : UserControl
{
public static DependencyProperty ISProperty = DependencyProperty.Register("IS",
typeof(string), typeof(MyUserControl), new PropertyMetadata(""));
[Category("Common Properties")]
public string IS
{
get { return (string)GetValue(ISProperty); }
set { SetValue(ISProperty, value); }
}
public MyUserControl()
{
InitializeComponent();
this.DataContext = this;
}
}