我正在WPF中使用RibbonController创建应用程序。

在我安装.net 4.6之前,它工作正常。然后,我的“RibbonGallery”处于禁用状态(“视点”下拉菜单)。我也尝试通过Code启用,但是没有运气;(。

<Custom:RibbonGallery SelectedValue="Entrancelobby" SelectedValuePath="Content" ScrollViewer.VerticalScrollBarVisibility="Visible" MaxHeight="500">
        <Custom:RibbonGalleryCategory Name="viewpointsList" FontFamily="Times New Roman" FontSize="14">
              <Custom:RibbonGalleryItem Content="Entrancelobby" Foreground="Black" />
              <Custom:RibbonGalleryItem Content="Entrancelobby 01" Foreground="Black"/>
        <Custom:RibbonGalleryCategory>
</Custom:RibbonGallery>

见附件
4.5 .net - .NET 4.6中禁用了RibbonGallery-LMLPHP没问题

.Net 4.6(issue) .net - .NET 4.6中禁用了RibbonGallery-LMLPHP

提前致谢...

最佳答案

这实际上是RibbonGallery中的一个错误,恰好由4.6.1中的新逻辑公开。漏洞是RG无法正确初始化其内部状态,因此,如果有人调用CoerceValue(IsEnabledProperty),它将把值强制设置为false(即禁用图库)。例如,调用ribbonGallery.IsEnabled = true;实际上将禁用RG(即使在4.0中也是如此)。

.Net 4.6.1具有更好的逻辑,可以将IsEnabled传播给后代。该逻辑最终调用ribbonGallery.CoerceValue(IsEnabledProperty),由于该错误,它禁用了RG。

有一个解决方法:更改RG的命令。这将导致RG正确地重置其内部状态,以便将来的强制执行正确的操作。例如:

ribbonGallery.Command = ApplicationCommands.Print;   // arbitrary command
ribbonGallery.Command = null;                        // don't keep the command

关于.net - .NET 4.6中禁用了RibbonGallery,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/34306045/

10-10 01:01
查看更多