xamarin - 如何在 Xamarin MAC 平台中更改选取器背景颜色

标签 xamarin xamarin.forms monodevelop xamarin-studio xamarin.mac

将 Xamarin 库和 MAC 操作系统更新到最新系统后,在我的 Visual Studio 2017 中,面临选择器背景颜色和在 MAC 平台选择器中选择/聚焦的项目颜色的问题。

填充多个值的选择器

Here is the picture of Picker that is filled with multiple value

打开选择器时无法设置背景颜色,并且所选项目因其颜色也不可见

On opening the picker can not able to set the background color and the item that is selected is also not visible because of its color.

如何设置该选择器的背景颜色以及选择器的焦点/选定项目的颜色?

最佳答案

这似乎是由 Mojave 使用的新主题引起的。

解决这个问题的一种方法是设置一个在浅色和深色上都可见的值,对我来说它适用于绿色。

将其添加到您的 XAML 中应该就足够了

<Picker.TextColor>
    <OnPlatform x:TypeArguments="Color">
        <On Platform="macOS" Value="Green"/>
    </OnPlatform>
</Picker.TextColor>

仅对您的 MacOs 项目进行更改,其他项目保持原样。

<Picker HorizontalOptions="CenterAndExpand" 
        VerticalOptions="CenterAndExpand">
    <Picker.Items>
        <x:String>Dell</x:String>
        <x:String>HP</x:String>
        <x:String>Mac</x:String>
        <x:String>Asus</x:String>
        <x:String>Lenovo</x:String>
        <x:String>Acer</x:String>
        <x:String>Micrsoft</x:String>
    </Picker.Items>
    <Picker.TextColor>
        <OnPlatform x:TypeArguments="Color">
            <On Platform="macOS" Value="Green"/>
        </OnPlatform>
    </Picker.TextColor>
</Picker>

注意:TextColor只会影响所选项目的文本颜色。

希望这有帮助。-

关于xamarin - 如何在 Xamarin MAC 平台中更改选取器背景颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53932894/

相关文章:

c# - Xamarin Android 绑定(bind)库 - 不在 DigitalPersona UareU JAR 中实现继承的抽象成员

visual-studio - MonoDevelop F# 类型和函数签名的工具提示;它们存在吗?

c# - VS for Mac 扩展 - ActiveWindow 中的空编辑器

c# - Xamarin Forms Switch 如何记住和更新用户设置(推送通知)

c# - 使用 Visual Studio 2013 构建 C/C++ DLL 并将其交付到 C# 应用程序中

c# - 使用 xamarin.forms 的 iOS 应用程序链接

oauth - 尝试在使用 OAuth 展示器时展示 UINavigationController

c# - Xamarin.Forms 如何使按钮显示在一行中

c# - log4net BasicConfigurator 未在控制台上打印

ios - Xamarin.IOS 和 Instruments 分析问题