How to change Picker font colour and size in Xamarin forms?

后端 未结 6 1669
梦如初夏
梦如初夏 2021-01-14 17:01

I\'m new to Xamarin and I\'m currently doing a project in Xamarin Forms PCL.

Is there a way to change the font colour and size of Picker?

  

6条回答
  •  迷失自我
    2021-01-14 18:00

    I Hope Below Code Helpful to Get Your TextColor

    **In Xaml**
    
     
    
    
    **In Code Behind**
    
     private void OnColorPickerSelected(object sender, EventArgs e)
     {
       ((ViewModel)BindingContext).Color= pkr_color.Items[pkr_color.SelectedIndex];
    
       ChooseColorPickerTextColor(((ViewModel)BindingContext).Color, pkr_color);
     }
    
    **Implement ChooseColorPickerTextColor Method Here**
    
      private void ChooseColorPickerTextColor(string selectedColor, Picker pickerName)
        {
            Picker colorPickerTextColor = pickerName;
    
            if (selectedColor == "Red")
            {
                colorPickerTextColor.TextColor = Color.Red;
            }
            else if (selectedColor == "Yellow")
            {
                colorPickerTextColor.TextColor = Color.Yellow;
            }
            else if (selectedColor == "Green")
            {
                colorPickerTextColor.TextColor = Color.Green;
            }
            else if (selectedColor == "Blue")
            {
                colorPickerTextColor.TextColor = Color.Blue;
            }
            else if (selectedColor == "Maroon")
            {
                colorPickerTextColor.TextColor = Color.Maroon;
            }
            else if (selectedColor == "Pink")
            {
                colorPickerTextColor.TextColor = Color.Pink;
            }
            else
            {
                colorPickerTextColor.TextColor = Color.Aqua;
            }
        }
    

    By using "WidthRequest" We can Increase size of the picker

提交回复
热议问题