私は WPF/XAML を使用しており、window
呼び出されたに基づいて独自のビューを定義しましたcontainer
。プロパティにリンクされcontainer
た DependencyProperty が呼び出されます。私の問題は、プロパティのメソッドがから呼び出されないことです。プロパティの登録中にtoを変更すると、呼び出されます。ほぼ間違いなく、登録中に何か間違ったことをしています。CurrentElementProperty
CurrentElement
set
DerivedContainer
typeof(Container)
typeof(DerivedContainer)
の定義Container
class Container : Window
{
public static readonly DependencyProperty CurrentElementProperty =
DependencyProperty.Register(
"CurrentElement",
typeof(Element),
typeof(Container),
new FrameworkPropertyMetadata(
null,
FrameworkPropertyMetadataOptions.Inherits));
public Element CurrentElement
{
get
{
return (Element)this.GetValue(Container.CurrentElementProperty);
}
set
{
this.SetValue(Container.CurrentElementProperty, value);
}
}
}
XAML のDerivedContainer
(標準の XML 名前空間定義を削除しました)
<local:Container x:Class="ns.DerivedContainer"
xmlns:local="clr-namespace:ns">
<local:Container.CurrentElement>
<Element />
</local:Container.CurrentElement>
</local:Container>
コードビハインドDerivedContainer
public partial class DerivedContainer : Container
{
public DerivedContainer()
{
InitializeComponent();
}
}