Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
为什么我在WPF中看到与数据网格的AreRowDetailsFrozen和HeadersVisibility相关的绑定错误?_Wpf_Xaml_Data Binding_Datagrid - Fatal编程技术网

为什么我在WPF中看到与数据网格的AreRowDetailsFrozen和HeadersVisibility相关的绑定错误?

为什么我在WPF中看到与数据网格的AreRowDetailsFrozen和HeadersVisibility相关的绑定错误?,wpf,xaml,data-binding,datagrid,Wpf,Xaml,Data Binding,Datagrid,System.Windows.Data错误:4:找不到与绑定的源 参考“相对资源查找器”, AncestorType='System.Windows.Controls.DataGrid',AncestorLevel='1'。 BindingExpression:Path=AreRowDetailsFrozen;DataItem=null;目标 元素是“DataGridDetailsPresenter”(名称=“”);目标属性为 “SelectiveScrollingOrientation”(键入

System.Windows.Data错误:4:找不到与绑定的源 参考“相对资源查找器”, AncestorType='System.Windows.Controls.DataGrid',AncestorLevel='1'。 BindingExpression:Path=AreRowDetailsFrozen;DataItem=null;目标 元素是“DataGridDetailsPresenter”(名称=“”);目标属性为 “SelectiveScrollingOrientation”(键入“SelectiveScrollingOrientation”) System.Windows.Data错误:4:找不到与绑定的源 参考“相对资源查找器”, AncestorType='System.Windows.Controls.DataGrid',AncestorLevel='1'。 BindingExpression:Path=HeadersVisibility;DataItem=null;目标 元素为“DataGridRowHeader”(名称=“”);目标属性为 “可见性”(键入“可见性”)

这些错误出现在WPF的即时窗口中。为什么会发生这种情况,我如何才能阻止它?

提供了解决此问题的详细方法。这一个对我有用:

将以下代码添加到全局样式:

<Style.Triggers>
     <Trigger Property="HeadersVisibility" Value="Column">         
          <Setter Property="RowHeaderWidth" Value="0" />
     </Trigger>
</Style.Triggers>

也有同样的问题。我制作了一个裸体WPF4.7应用程序,在我的例子中,SizeToContent属性导致了它

我有一个状态栏,其DataContext设置为RelativeSource AncestorType=Window,DataGrid是DockPanel中这两者的同级。根窗口的SizeToContent设置为Width


将项添加到DataGrid时,会出现您描述的绑定错误。没有内容,他们就没有。在状态栏中使用ElementName=rootWindow而不是祖先的诡计也修复了它。

到帖子的链接已更改。今天(2018年),它指出了一系列讨论。您仍然可以通过标题找到讨论:“DataGrid.HeadersVisibility的Bug?”