c# - 如何更改 XAMARIN 中 Picker 占位符的颜色?

标签 c# android ios xaml xamarin

如何在 XAMARIN for ANDROID 和 iOS 中更改 Picker 占位符的颜色? PlaceholderColor = "white"不起作用。

            <Picker Title="Search items"  TextColor="White"
            PlaceholderColor = "white"
            VerticalOptions="Start">
            <Picker.Items>
                <x:String>Item1</x:String>
                <x:String>item2</x:String>
                <x:String>item3</x:String>
            </Picker.Items>
        </Picker>

最佳答案

对于 xamarin 3.6 及更高版本:

使用属性 TitleColor

对于 Xamarin 3.6 及以下版本:

为此你需要一个自定义渲染器:

[assembly: ExportRenderer(typeof(Picker), typeof(CustomPicker))]
namespace Droid
{
    public class CustomPicker : PickerRenderer
    {

        protected override void OnElementChanged(ElementChangedEventArgs<Picker> e)
        {
            base.OnElementChanged (e);

            if (Control != null) 
                Control.SetHintTextColor (Android.Graphics.Color.Rgb(1,2,3));

        }

    }

}

关于c# - 如何更改 XAMARIN 中 Picker 占位符的颜色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50846939/

相关文章:

c# - 共享图像仅显示两个选项,Mail 和 Onenote

c# - 为什么 C# 为相同的源代码生成不同的 EXE?

java - 我在此代码中收到 can't pass null for argument 'pathString' in child() 错误

android - 如何访问android库项目中的资源

ios - 基于动态位置的本地通知 Swift iOS

iphone - 如何为加载的 TableView 显示 UIActivityIndi​​catorView

ios - 避免触发 touchesBegan : until a swipe gesture recognizer fails

c# - Post FromBody 始终为空

c# - 请等待按钮上的加载栏单击未显示

android - 重复调用 LineBackgroundSpan drawBackground()