我試圖獲取當前用戶界面,強調色彩使用下面的代碼UWP平臺上:UWP v10240 GetAccentColor
var uiSettings = new UISettings();
var accentColor = uiSettings.GetColorValue(UIColorType.Accent);
此代碼爲v10586和v14939但未能爲v10240但下列情況除外:
Unable to cast object of
type 'Windows.UI.ViewManagement.UISettings' to
type 'Windows.UI.ViewManagement.IUISettings3'.
問題:爲什麼不與v10240工作此代碼儘管該方法是在所使用的ApiContract [大會Windows.Foundation.UniversalApiContract,版本定義= 1.0.0.0]並且所有的AccentColor-EnumValues也在ApiContract v1中定義?儘管文檔沒有提示這樣的例外,但避免這種錯誤的最佳做法是什麼?
的文檔指定所用方法的可用性v10240:UISettings::GetColorValue和所使用的枚舉:UIColorType
我已經找到了StackOverflow上Get Variations of Accent color in UWP,但這並沒有解決我的問題。 https://github.com/janjaali/UwpGetAccentColorVs10240