私は私のUserControl
<UserControl x:Class="CustomCtrl.MyButton">
<Button x:Name="Btn" />
</UserControl>
そして、私は私UserControl
のものをWindow
<Window>
<Grid>
<MyButton Background="Aqua" />
</Grid>
</Window>
my with XAMLのプロパティを使用してBackground
、 Buttonのプロパティを変更したいと考えています。Btn
Background
UserControl
Background
プロパティを追加してみました
public class MyButton: UserControl
{
public new Brush Background
{
get
{ return Btn.GetValue(BackgroundProperty) as Brush; }
set
{ Btn.SetValue(BackgroundProperty, value); }
}
}
しかし、それは効果がありません。
代わりにコードを使用するとMyButtonControl.Background = Brushes.Aqua;
、機能します。
なんで?この問題を解決するにはどうすればよいですか?