从DP回调WPF更新WindowsFormsHost控件

从DP回调WPF更新WindowsFormsHost控件,wpf,mvvm,binding,dependency-properties,Wpf,Mvvm,Binding,Dependency Properties,我在WindowsFormsHost中的DataGridView周围有一个usercontrol包装器 包装器有一个带有回调的DP,但回调是静态的,因此它不能简单地在具有x:Name的windowsforms托管控件上执行代码 更新DP时,如何更新WindowsFormsHost DataGridView 我想这样做,但是我不能在DP回调中引用_gridView public LiteTable GridViewData { get { return (LiteTabl

我在WindowsFormsHost中的DataGridView周围有一个usercontrol包装器

包装器有一个带有回调的DP,但回调是静态的,因此它不能简单地在具有x:Name的windowsforms托管控件上执行代码

更新DP时,如何更新WindowsFormsHost DataGridView

我想这样做,但是我不能在DP回调中引用_gridView

 public LiteTable GridViewData
    {
        get { return (LiteTable)GetValue(GridViewDataProperty); }
        set { SetValue(GridViewDataProperty, value); }
    }

    private static void OnGridViewDataChanged(DependencyObject source, DependencyPropertyChangedEventArgs e)
    {
        _gridView.GetData((LiteTable)e.NewValue);
    }

    // Using a DependencyProperty as the backing store for GridViewData.  This enables animation, styling, binding, etc...
    public static readonly DependencyProperty GridViewDataProperty =
        DependencyProperty.Register("GridViewData", typeof(LiteTable), typeof(LiteGridViewWrapper), new UIPropertyMetadata(null, OnGridViewDataChanged));

WPF传递其属性在
参数中更改的实例。
您可以将此参数强制转换为您的类型并获取字段

var me = (MyControl)source;
me._gridView.GetData((LiteTable)e.NewValue);