Mvvm 当我尝试创建DependencyProperty时:找不到治理FrameworkElement或FrameworkContentElement

Mvvm 当我尝试创建DependencyProperty时:找不到治理FrameworkElement或FrameworkContentElement,mvvm,datagridcomboboxcolumn,Mvvm,Datagridcomboboxcolumn,我正在通过从DataGridBoundColumn继承来构建自定义DataGridColumn,但当我尝试创建dependencProperty时,此错误会出现在输出窗口中 System.Windows.Data错误:2:找不到治理框架元素 或目标元素的FrameworkContentElement。 BindingExpression:Path=myViewModelProperty;DataItem=null;目标元素是 “CustomDataGridComboxColumn”(HashCo

我正在通过从
DataGridBoundColumn
继承来构建自定义
DataGridColumn
,但当我尝试创建
dependencProperty
时,此错误会出现在输出窗口中

System.Windows.Data错误:2:找不到治理框架元素 或目标元素的FrameworkContentElement。 BindingExpression:Path=myViewModelProperty;DataItem=null;目标元素是 “CustomDataGridComboxColumn”(HashCode=24500989);目标属性为 'ItemsSourcePath'(类型'Object')

我在DataGridColumns中读到了DataContext,听说这个对象不属于可视树。但我无法找到让他们从其父代继承DataContext的方法

这是我使用的代码

    public partial class CustomGridComboBoxColumn : DataGridBoundColumn
    {
        //The value indicating where to get the itemsSource
        public static readonly DependencyProperty ItemsSourcePathProperty = DependencyProperty.Register(
                "ItemsSourcePath",
                typeof(string),
                typeof(CustomGridComboBoxColumn));
    }
    /// <summary>
    /// Gets or set the related collection 
    /// </summary>
    public string ItemsSourcePath
    {
        get
        {
          return (string)GetValue(ItemsSourcePathProperty);
        }
        set
        {
           SetValue(ItemsSourcePathProperty, value);
        }
    }
我正试着这样使用它

<cc:CustomDataGridComboBoxColumn Header="New Column" ItemsSourcePath="{Binding myViewModelProperty}"/>

<cc:CustomDataGridComboBoxColumn Header="New Column" ItemsSourcePath="{Binding myViewModelProperty}"/>