|
2 | 2 |
|
3 | 3 | namespace TabbedPageDemo
|
4 | 4 | {
|
5 |
| - public class TabbedPageDemoPageCS : TabbedPage |
6 |
| - { |
7 |
| - public TabbedPageDemoPageCS () |
8 |
| - { |
9 |
| - var booleanConverter = new NonNullToBooleanConverter (); |
| 5 | + public class TabbedPageDemoPageCS : TabbedPage |
| 6 | + { |
| 7 | + public TabbedPageDemoPageCS() |
| 8 | + { |
| 9 | + var booleanConverter = new NonNullToBooleanConverter(); |
10 | 10 |
|
11 |
| - ItemTemplate = new DataTemplate (() => { |
12 |
| - var nameLabel = new Label { |
13 |
| - FontSize = Device.GetNamedSize (NamedSize.Large, typeof(Label)), |
14 |
| - FontAttributes = FontAttributes.Bold, |
15 |
| - HorizontalOptions = LayoutOptions.Center |
16 |
| - }; |
17 |
| - nameLabel.SetBinding (Label.TextProperty, "Name"); |
| 11 | + ItemTemplate = new DataTemplate(() => |
| 12 | + { |
| 13 | + var nameLabel = new Label |
| 14 | + { |
| 15 | + FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Label)), |
| 16 | + FontAttributes = FontAttributes.Bold, |
| 17 | + HorizontalOptions = LayoutOptions.Center |
| 18 | + }; |
| 19 | + nameLabel.SetBinding(Label.TextProperty, "Name"); |
18 | 20 |
|
19 |
| - var image = new Image { WidthRequest = 200, HeightRequest = 200 }; |
20 |
| - image.SetBinding (Image.SourceProperty, "PhotoUrl"); |
| 21 | + var image = new Image { WidthRequest = 200, HeightRequest = 200 }; |
| 22 | + image.SetBinding(Image.SourceProperty, "PhotoUrl"); |
21 | 23 |
|
22 |
| - var familyLabel = new Label { |
23 |
| - FontSize = Device.GetNamedSize (NamedSize.Medium, typeof(Label)), |
24 |
| - FontAttributes = FontAttributes.Bold |
25 |
| - }; |
26 |
| - familyLabel.SetBinding (Label.TextProperty, "Family"); |
| 24 | + var familyLabel = new Label |
| 25 | + { |
| 26 | + FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)), |
| 27 | + FontAttributes = FontAttributes.Bold |
| 28 | + }; |
| 29 | + familyLabel.SetBinding(Label.TextProperty, "Family"); |
27 | 30 |
|
28 |
| - var subFamilyLabel = new Label { |
29 |
| - FontSize = Device.GetNamedSize (NamedSize.Medium, typeof(Label)), |
30 |
| - FontAttributes = FontAttributes.Bold |
31 |
| - }; |
32 |
| - subFamilyLabel.SetBinding (Label.TextProperty, "Subfamily"); |
| 31 | + var subFamilyLabel = new Label |
| 32 | + { |
| 33 | + FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)), |
| 34 | + FontAttributes = FontAttributes.Bold |
| 35 | + }; |
| 36 | + subFamilyLabel.SetBinding(Label.TextProperty, "Subfamily"); |
33 | 37 |
|
34 |
| - var tribeLabel = new Label { |
35 |
| - FontSize = Device.GetNamedSize (NamedSize.Medium, typeof(Label)), |
36 |
| - FontAttributes = FontAttributes.Bold |
37 |
| - }; |
38 |
| - tribeLabel.SetBinding (Label.TextProperty, "Tribe"); |
| 38 | + var tribeLabel = new Label |
| 39 | + { |
| 40 | + FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)), |
| 41 | + FontAttributes = FontAttributes.Bold |
| 42 | + }; |
| 43 | + tribeLabel.SetBinding(Label.TextProperty, "Tribe"); |
39 | 44 |
|
40 |
| - var genusLabel = new Label { |
41 |
| - FontSize = Device.GetNamedSize (NamedSize.Medium, typeof(Label)), |
42 |
| - FontAttributes = FontAttributes.Bold |
43 |
| - }; |
44 |
| - genusLabel.SetBinding (Label.TextProperty, "Genus"); |
| 45 | + var genusLabel = new Label |
| 46 | + { |
| 47 | + FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)), |
| 48 | + FontAttributes = FontAttributes.Bold |
| 49 | + }; |
| 50 | + genusLabel.SetBinding(Label.TextProperty, "Genus"); |
45 | 51 |
|
46 |
| - var subFamilyStackLayout = new StackLayout { |
47 |
| - Orientation = StackOrientation.Horizontal, |
48 |
| - Children = { |
49 |
| - new Label { Text = "Subfamily:", HorizontalOptions = LayoutOptions.FillAndExpand }, |
50 |
| - subFamilyLabel |
51 |
| - } |
52 |
| - }; |
53 |
| - subFamilyStackLayout.SetBinding (VisualElement.IsVisibleProperty, new Binding ("Subfamily", BindingMode.Default, booleanConverter)); |
| 52 | + var subFamilyStackLayout = new StackLayout |
| 53 | + { |
| 54 | + Orientation = StackOrientation.Horizontal, |
| 55 | + Children = |
| 56 | + { |
| 57 | + new Label { Text = "Subfamily:", HorizontalOptions = LayoutOptions.FillAndExpand }, |
| 58 | + subFamilyLabel |
| 59 | + } |
| 60 | + }; |
| 61 | + subFamilyStackLayout.SetBinding(VisualElement.IsVisibleProperty, new Binding("Subfamily", BindingMode.Default, booleanConverter)); |
54 | 62 |
|
55 |
| - var tribeStackLayout = new StackLayout { |
56 |
| - Orientation = StackOrientation.Horizontal, |
57 |
| - Children = { |
58 |
| - new Label { Text = "Tribe:", HorizontalOptions = LayoutOptions.FillAndExpand }, |
59 |
| - tribeLabel |
60 |
| - } |
61 |
| - }; |
62 |
| - tribeStackLayout.SetBinding (VisualElement.IsVisibleProperty, new Binding ("Tribe", BindingMode.Default, booleanConverter)); |
| 63 | + var tribeStackLayout = new StackLayout |
| 64 | + { |
| 65 | + Orientation = StackOrientation.Horizontal, |
| 66 | + Children = |
| 67 | + { |
| 68 | + new Label { Text = "Tribe:", HorizontalOptions = LayoutOptions.FillAndExpand }, |
| 69 | + tribeLabel |
| 70 | + } |
| 71 | + }; |
| 72 | + tribeStackLayout.SetBinding(VisualElement.IsVisibleProperty, new Binding("Tribe", BindingMode.Default, booleanConverter)); |
63 | 73 |
|
64 |
| - var contentPage = new ContentPage { |
65 |
| - IconImageSource = "monkeyicon.png", |
66 |
| - Content = new StackLayout { |
67 |
| - Padding = new Thickness (5, 25), |
68 |
| - Children = { |
69 |
| - nameLabel, |
70 |
| - image, |
71 |
| - new StackLayout { |
72 |
| - Padding = new Thickness (50, 10), |
73 |
| - Children = { |
74 |
| - new StackLayout { |
75 |
| - Orientation = StackOrientation.Horizontal, |
76 |
| - Children = { |
77 |
| - new Label { Text = "Family:", HorizontalOptions = LayoutOptions.FillAndExpand }, |
78 |
| - familyLabel |
79 |
| - } |
80 |
| - }, |
81 |
| - subFamilyStackLayout, |
82 |
| - tribeStackLayout, |
83 |
| - new StackLayout { |
84 |
| - Orientation = StackOrientation.Horizontal, |
85 |
| - Children = { |
86 |
| - new Label { Text = "Genus:", HorizontalOptions = LayoutOptions.FillAndExpand }, |
87 |
| - genusLabel |
88 |
| - } |
89 |
| - } |
90 |
| - } |
91 |
| - } |
| 74 | + var contentPage = new ContentPage |
| 75 | + { |
| 76 | + IconImageSource = "monkeyicon.png", |
| 77 | + Content = new StackLayout |
| 78 | + { |
| 79 | + Padding = new Thickness(5, 25), |
| 80 | + Children = |
| 81 | + { |
| 82 | + nameLabel, |
| 83 | + image, |
| 84 | + new StackLayout |
| 85 | + { |
| 86 | + Padding = new Thickness (50, 10), |
| 87 | + Children = |
| 88 | + { |
| 89 | + new StackLayout |
| 90 | + { |
| 91 | + Orientation = StackOrientation.Horizontal, |
| 92 | + Children = |
| 93 | + { |
| 94 | + new Label { Text = "Family:", HorizontalOptions = LayoutOptions.FillAndExpand }, |
| 95 | + familyLabel |
| 96 | + } |
| 97 | + }, |
| 98 | + subFamilyStackLayout, |
| 99 | + tribeStackLayout, |
| 100 | + new StackLayout |
| 101 | + { |
| 102 | + Orientation = StackOrientation.Horizontal, |
| 103 | + Children = |
| 104 | + { |
| 105 | + new Label { Text = "Genus:", HorizontalOptions = LayoutOptions.FillAndExpand }, |
| 106 | + genusLabel |
| 107 | + } |
| 108 | + } |
| 109 | + } |
| 110 | + } |
92 | 111 |
|
93 |
| - } |
94 |
| - } |
95 |
| - }; |
96 |
| - contentPage.SetBinding (TitleProperty, "Name"); |
| 112 | + } |
| 113 | + } |
| 114 | + }; |
| 115 | + contentPage.SetBinding(TitleProperty, "Name"); |
97 | 116 |
|
98 |
| - return contentPage; |
99 |
| - }); |
| 117 | + return contentPage; |
| 118 | + }); |
100 | 119 |
|
101 |
| - ItemsSource = MonkeyDataModel.All; |
102 |
| - } |
103 |
| - } |
| 120 | + ItemsSource = MonkeyDataModel.All; |
| 121 | + } |
| 122 | + } |
104 | 123 | }
|
0 commit comments