【发布时间】:2011-08-10 17:28:59
【问题描述】:
我在 WindowsFormsHost 中的 DataGridView 周围有一个用户控件包装器。
包装器有一个带有回调的 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 mvvm binding dependency-properties