在常规窗口(而不是RibbonWindow)中使用时,功能区绑定失败

问题描述 投票:5回答:2

我正在使用RibbonControlLibrary中的Ribbon控件来处理.net 3.5。

我不能使用RibbonWindow来解决一些表示兼容性问题。所以我将一个Ribbon控件放在Window中。

没有明显的问题,但我在VisualStudio输出窗口中收到2条错误消息。

这些消息是:

  1. System.Windows.Data错误:4:无法找到绑定源,引用'RelativeSource FindAncestor,AncestorType ='Microsoft.Windows.Controls.Ribbon.RibbonWindow',AncestorLevel ='1''。 BindingExpression:路径=的WindowState;的DataItem = NULL; target元素是'Ribbon'(Name =''); target属性是'NoTarget'(类型'对象')
  2. System.Windows.Data错误:4:无法找到绑定源,引用'RelativeSource FindAncestor,AncestorType ='Microsoft.Windows.Controls.Ribbon.RibbonWindow',AncestorLevel ='1''。 BindingExpression:路径= IsActive;的DataItem = NULL; target元素是'Ribbon'(Name =''); target属性是'NoTarget'(类型'对象')

只需将Ribbon添加到Window并运行应用程序即可重现。

有没有办法告诉Ribbon不要尝试将任何内容完全绑定到RibbonWindow但是对于Window?

wpf binding .net-3.5 ribbon
2个回答
1
投票

既然你说你不能使用RibbonWindow(出于某种原因......),我假设你正在做类似的事情

<Window x:Class="Yournamespace" ...>
    <Ribbon>
    </Ribbon>
</Window>

你的祖先应该是AncestorType='System.Windows.Window'而不是'Microsoft.Windows.Controls.Ribbon.RibbonWindow'


-1
投票

你可能有:

<Window x:Class="yournamespace" 
    xmlns:r="clr-namespace:Microsoft.Windows.Controls.Ribbon;assembly=RibbonControlsLibrary"
...>
    <r:Ribbon>
    </r:Ribbon>
</Window>

To fix this just replace <Window> and </Window> with <r:RibbonWindow> and </r:RibbonWindow>

这为我修好了

© www.soinside.com 2019 - 2024. All rights reserved.