0
カスタムユーザーコントロールに2つの依存関係プロパティ(両方の文字列リスト)があります。これらの依存関係プロパティのバインディングは、アプリケーションの有効期間。私はバインディングが変更されたときにユーザーコントロールで何らかのアクションを実行する必要があり、アクションを実行するためにクラスのすべての依存関係プロパティにアクセスする必要があります。例えば、依存関係プロパティを持つシナリオ - お互いにアクセスする方法
public class UC:UserControl
{
public List<string> AvailableItems
{
get { return (List<string>)this.GetValue(AvailableItemsProperty); }
set { this.SetValue(AvailableItemsProperty, value); }
}
public static readonly DependencyProperty AvailableItemsProperty = DependencyProperty.Register(
"AvailableItems", typeof(List<string>), typeof(ItemSelectionUserControl), new FrameworkPropertyMetadata(OnAvailableItemsChanged) { BindsTwoWayByDefault = true });
public List<string> SelectedItems
{
get { return (List<string>)this.GetValue(SelectedItemsProperty); }
set { this.SetValue(SelectedItemsProperty, value); }
}
public static readonly DependencyProperty SelectedItemsProperty = DependencyProperty.Register(
"SelectedItems", typeof(List<string>), typeof(ItemSelectionUserControl), new FrameworkPropertyMetadata { BindsTwoWayByDefault = true });
public static void OnAvailableItemsChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
{
//How to access SelectedItems here??
}
}
トラブルは、依存関係プロパティが変更され、コールバックが静的でなければなりませんので、どのように私は、関数内の非静的な依存関係プロパティのラッパーにアクセスすることができます
です??またはこれを行う他の方法はありますか?
はあなたのアミットありがとうございます。 – Jimmy