如何在Xamarin MAC平台中更改Picker背景颜色 [英] How to change Picker background Color in Xamarin MAC Platform

查看:128
本文介绍了如何在Xamarin MAC平台中更改Picker背景颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

将Xamarin库和MAC OS更新到最新系统后,在我的Visual Studio 2017中,拾取器背景颜色和在MAC平台的拾取器中选择/集中的项目的颜色面临问题.

After updating the Xamarin Library and MAC OS to latest system, facing issue in Picker Background color and color of item that is selected/focused in picker for MAC Platform in my visual studio 2017.

由多个值填充的选择器

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

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

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

How can I set the background color of that picker and the color of that focused/selected item of picker?

推荐答案

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

This seems to be caused for the new Theme used by Mojave.

解决此问题的一种方法是设置一个值,使它们在浅色和深色上均可见,对我来说,它可以使绿色起作用.

One way to overcome this issue is by setting a value that will be visible on both Light and Dark them, for me it worked the Green.

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

Adding this to your XAML should be sufficient

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

仅在MacOs项目上进行更改,而其他项目保持不变.

Making the change only on your MacOs project leaving the others as they are.

<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仅会影响所选项目的文本颜色.

Note: The TextColor will only affect the selected item text color.

希望这会有所帮助.-

这篇关于如何在Xamarin MAC平台中更改Picker背景颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆