forked from reactiveui/ReactiveUI
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAndroidDefaultPropertyBinding.cs
More file actions
29 lines (26 loc) · 966 Bytes
/
AndroidDefaultPropertyBinding.cs
File metadata and controls
29 lines (26 loc) · 966 Bytes
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
using System;
using System.Linq;
using ReactiveUI;
using Android.Widget;
namespace ReactiveUI
{
/// <summary>
/// Default property bindings for common Android widgets
/// </summary>
public class AndroidDefaultPropertyBinding : IDefaultPropertyBindingProvider
{
public Tuple<string, int> GetPropertyForControl(object control)
{
// NB: These are intentionally arranged in priority order from most
// specific to least specific.
var items = new[] {
new { Type = typeof(TextView), Property = "Text" },
new { Type = typeof(ProgressBar), Property = "Progress" },
new { Type = typeof(CompoundButton), Property = "Checked" },
};
var type = control.GetType();
var kvp = items.FirstOrDefault(x => x.Type.IsAssignableFrom(type));
return kvp != null ? Tuple.Create(kvp.Property, 5) : null;
}
}
}