Answer the question
In order to leave comments, you need to log in
Why does Picker have a different view when rendering in xamarin forms?
Good day).
I'm using a custom rendering Picker to change the color of the line, but it also changes the look of the window.
Tell me how to keep the original view of the android when rendering?
Picker original
PickerRenderer
<local:PickerCus
x:Name="hous"
Grid.Column="1" Grid.Row="2"
Style="{StaticResource Picker}">
<Picker.Items>
<x:String>Свой дом</x:String>
<x:String>Снимает</x:String>
<x:String>Общежитие</x:String>
<x:String>Временно живет у друзей</x:String>
<x:String>Временно живет у родственников</x:String>
</Picker.Items>
</local:PickerCus>
[assembly: ExportRenderer(typeof(PickerCus), typeof(CustomPickerRenderer))]
namespace PsihoProfile.Droid
{
class CustomPickerRenderer: PickerRenderer
{
private Context context;
public CustomPickerRenderer(Context context) : base(context)
{
this.context = context;
}
protected override void OnElementChanged(ElementChangedEventArgs<Picker> e)
{
base.OnElementChanged(e);
if (Control == null || e.NewElement == null) return;
//for example ,change the line to red:
if (Build.VERSION.SdkInt >= BuildVersionCodes.Lollipop)
Control.BackgroundTintList = ColorStateList.ValueOf(Color.White);
else
Control.Background.SetColorFilter(Color.White, PorterDuff.Mode.SrcAtop);
}
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question