RibbonGallery disabled in .net 4.6

纵然是瞬间 提交于 2019-12-08 16:38:27

问题


I'm creating an application using RibbonController in WPF.

It's working fine until i installed .net 4.6. Then my "RibbonGallery" is disabled state (Viewpoints Drop Down menu) . I tried to enable through Code also but no luck ;(.

<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>

See attachments No issue with 4.5

.Net 4.6 (issue)

Thanks in advance...


回答1:


This is actually a bug in RibbonGallery that just happens to be exposed by new logic in 4.6.1. The bug is that RG doesn't initialize its internal state correctly, so that if anyone calls CoerceValue(IsEnabledProperty) it coerces the value to false (i.e. disables the gallery). For example, calling ribbonGallery.IsEnabled = true; will actually disable the RG (even in 4.0).

.Net 4.6.1 has better logic for propagating IsEnabled to descendants. This logic ends up calling ribbonGallery.CoerceValue(IsEnabledProperty), which disables the RG due to the bug.

There's a workaround: Change the RG's Command. This causes the RG to reset its internal state correctly, so that future coercions do the right thing. For example:

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



回答2:


Disabled items in RibbonGallery is the same issue I’m getting, once IsEnabled is set to false I can’t enable again. This was working previously and noticed since updating to Net 4.6 on the PC. I’ve run an old program from a few years back without any recompilation and it suffers from the same fate. So even if Net 4.5 is targeted it will exhibit the same problem as it’s associated to the PC .Net installed. If the PC uses Windows 10 the Net framework can’t be rolled back to Net 4.5 as it uses 4.6 minimum right?

Tried setting the Command to null but this was unsuccessful. Tried Net 4.6.1 installed on PC and various combinations targeted but unsuccessful. For me I think I’ll rip out the Microsoft ribbon stuff which has always seemed a buggy afterthought costing me in development time.



来源:https://stackoverflow.com/questions/34306045/ribbongallery-disabled-in-net-4-6

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!