This repository was 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
/
Copy pathIssue1769.cs
86 lines (74 loc) · 1.84 KB
/
Issue1769.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms.CustomAttributes;
using Xamarin.Forms.Internals;
namespace Xamarin.Forms.Controls
{
[Preserve (AllMembers=true)]
[Issue (IssueTracker.Github, 1769, "PushAsync with Switch produces NRE", PlatformAffected.Android)]
public class Issue1769
: ContentPage
{
public Issue1769()
{
var button = new Button()
{
Text = "Go To Page 2"
};
var switchDemo = new SwitchDemoPage();
button.Clicked += async (sender, args) => {
await ((Button)sender).Navigation.PushAsync(switchDemo);
};
Content = button;
}
class SwitchDemoPage : ContentPage
{
Label _label;
public SwitchDemoPage()
{
Label header = new Label
{
Text = "Switch",
#pragma warning disable 618
Font = Font.BoldSystemFontOfSize(50),
#pragma warning restore 618
HorizontalOptions = LayoutOptions.Center
};
Switch switcher = new Switch
{
HorizontalOptions = LayoutOptions.Center,
VerticalOptions = LayoutOptions.CenterAndExpand
};
switcher.Toggled += switcher_Toggled;
_label = new Label
{
Text = "Switch is now False",
#pragma warning disable 618
Font = Font.SystemFontOfSize(NamedSize.Large),
#pragma warning restore 618
HorizontalOptions = LayoutOptions.Center,
VerticalOptions = LayoutOptions.CenterAndExpand
};
// Accomodate iPhone status bar.
Padding = Device.RuntimePlatform == Device.iOS ? new Thickness(10, 20, 10, 5) : new Thickness(10, 0, 10, 5);
// Build the page.
Content = new StackLayout
{
Children =
{
header,
switcher,
_label
}
};
}
void switcher_Toggled(object sender, ToggledEventArgs e)
{
_label.Text = string.Format("Switch is now {0}", e.Value);
}
}
}
}