Dot-Net
RibbonGallery 在 .net 4.6 中被禁用
我正在 WPF 中使用 RibbonController 創建一個應用程序。
在我安裝 .net 4.6 之前它工作正常。然後我的“RibbonGallery”處於禁用狀態(觀點下拉菜單)。我也嘗試通過程式碼啟用,但沒有運氣;(。
<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>提前致謝…
這實際上是 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

