-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
MaterialPickerRenderer.cs
58 lines (53 loc) · 1.29 KB
/
MaterialPickerRenderer.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
using System;
using Xamarin.Forms;
using Xamarin.Forms.Material.Tizen;
using Xamarin.Forms.Material.Tizen.Native;
using Xamarin.Forms.Platform.Tizen;
[assembly: ExportRenderer(typeof(Picker), typeof(MaterialPickerRenderer), new[] { typeof(VisualMarker.MaterialVisual) }, Priority = short.MinValue)]
namespace Xamarin.Forms.Material.Tizen
{
public class MaterialPickerRenderer : PickerRenderer
{
Color _defaultTitleColor = Color.Black;
protected override ElmSharp.Entry CreateNativeControl()
{
return new MPicker(Forms.NativeParent);
}
protected override void UpdateSelectedIndex()
{
if (Control is MPicker mp)
{
mp.Placeholder = (Element.SelectedIndex == -1 || Element.Items == null ?
"" : Element.Items[Element.SelectedIndex]);
}
}
protected override void UpdateTitleColor()
{
if (Control is MPicker mp)
{
if (Element.TitleColor.IsDefault)
{
mp.PlaceholderColor = _defaultTitleColor.ToNative();
}
else
{
mp.PlaceholderColor = Element.TitleColor.ToNative();
}
}
}
protected override void UpdateTextColor()
{
if (Control is MPicker mp)
{
if (Element.TextColor.IsDefault)
{
mp.TextColor = _defaultTitleColor.ToNative();
}
else
{
mp.TextColor = Element.TextColor.ToNative();
}
}
}
}
}