This repository has been archived by the owner on May 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
/
Github7996.cs
111 lines (97 loc) · 2.27 KB
/
Github7996.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
using System.ComponentModel;
using System.Globalization;
using Xamarin.Forms.CustomAttributes;
using Xamarin.Forms.Internals;
#if UITEST
using Xamarin.Forms.Core.UITests;
using Xamarin.UITest;
using NUnit.Framework;
#endif
namespace Xamarin.Forms.Controls.Issues
{
[Preserve(AllMembers = true)]
[Issue(IssueTracker.Github, 7996, "Xamarin.Forms.Entry does not enter decimal when binding a float/double and decimal to it", PlatformAffected.Default)]
public class Issue7996 : TestContentPage
{
protected override void Init()
{
var vm = new ViewModelIssue7996();
BindingContext = vm;
var textLabel1 = new Label
{
Text = "Select culture:"
};
var picker = new Picker();
picker.ItemsSource = new[]
{
new CultureInfo("de"),
new CultureInfo("en"),
};
picker.SelectedIndexChanged += (s, e) =>
{
if (picker.SelectedItem is CultureInfo culture)
{
CultureInfo.CurrentUICulture = culture;
}
};
var textLabel2 = new Label
{
Text = "Resolved Binding Value:"
};
var bindingLable = new Label();
bindingLable.SetBinding(Label.TextProperty, new Binding(nameof(ViewModelIssue7996.MyDecimal), BindingMode.TwoWay));
var textLabel3 = new Label
{
Text = "Actual Value:"
};
var bindingLable2 = new Label();
bindingLable2.SetBinding(Label.TextProperty, new Binding(nameof(ViewModelIssue7996.MyDecimal), BindingMode.TwoWay));
var textLabel4 = new Label
{
Text = "Enter a number and watch result:"
};
var entry = new Entry();
entry.Text = vm.MyDecimal.ToString();
entry.TextChanged += (s, e) =>
{
bindingLable.Text = e.NewTextValue;
};
var stackLayout = new StackLayout
{
Children =
{
textLabel1,
picker,
textLabel2,
bindingLable,
textLabel3,
bindingLable2,
textLabel4,
entry,
}
};
Content = stackLayout;
}
}
[Preserve(AllMembers = true)]
public class ViewModelIssue7996 : INotifyPropertyChanged
{
decimal? myDecimal = 4.2m;
public event PropertyChangedEventHandler PropertyChanged;
public decimal? MyDecimal
{
get
{
return myDecimal;
}
set
{
myDecimal = value;
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(MyDecimal)));
}
}
public ViewModelIssue7996()
{
}
}
}