Wpf Caliburn Micro:DataGrid中ComboBox的ElementName不工作

Wpf Caliburn Micro:DataGrid中ComboBox的ElementName不工作,wpf,xaml,combobox,caliburn.micro,elementname,Wpf,Xaml,Combobox,Caliburn.micro,Elementname,我的问题是DataGrid中ComboBox的ItemsSource没有绑定。 我的用户控件: <UserControl x:Class="MyClass" x:Name="Root" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/

我的问题是DataGrid中ComboBox的ItemsSource没有绑定。 我的用户控件:

<UserControl x:Class="MyClass"
             x:Name="Root"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:cal="clr-namespace:Caliburn.Micro;assembly=Caliburn.Micro" 
             mc:Ignorable="d" 
             d:DesignHeight="360" d:DesignWidth="757">
FilteredArticle是我的ViewModel中的BindableCollection。所有其他绑定都在工作。 这里怎么了?
使用最新稳定版本的Caliburn.Micro。

通过
ElementName
绑定到视图通常是一种不好的做法。主要是因为创建视图实例的人可以给它一个不同的
x:Name
,这将破坏您的内部绑定

另外,
FilteredArticle
属性不是视图的属性,而是视图模型的属性,视图模型是视图的数据上下文

在这些场景中使用相对源进行绑定

ItemsSource="{Binding DataContext.FilteredArticle, 
                      RelativeSource={RelativeSource FindAncestor, 
                                             AncestorType={x:Type UserControl}}}"
您可以使用更具体的表示法(尽管在99%的情况下不需要)


其中
local
MyClass
命名空间的
xmlns
,通过
ElementName
绑定到视图通常是一种不好的做法。主要是因为创建视图实例的人可以给它一个不同的
x:Name
,这将破坏您的内部绑定

另外,
FilteredArticle
属性不是视图的属性,而是视图模型的属性,视图模型是视图的数据上下文

在这些场景中使用相对源进行绑定

ItemsSource="{Binding DataContext.FilteredArticle, 
                      RelativeSource={RelativeSource FindAncestor, 
                                             AncestorType={x:Type UserControl}}}"
您可以使用更具体的表示法(尽管在99%的情况下不需要)

其中
local
MyClass

ItemsSource="{Binding DataContext.FilteredArticle, 
                      RelativeSource={RelativeSource FindAncestor, 
                                             AncestorType={x:Type UserControl}}}"
ItemsSource="{Binding DataContext.FilteredArticle, 
                      RelativeSource={RelativeSource FindAncestor, 
                                             AncestorType={x:Type local:MyClass}}}"