Skip to content
This repository was archived by the owner on Apr 29, 2024. It is now read-only.

Commit 419fa9e

Browse files
committed
Formatting updates.
1 parent 0cdf0f5 commit 419fa9e

File tree

5 files changed

+172
-150
lines changed

5 files changed

+172
-150
lines changed

Navigation/TabbedPage/TabbedPageDemo/TabbedPageDemo/MonkeyDataModel.cs

100755100644
+47-43
Original file line numberDiff line numberDiff line change
@@ -3,47 +3,51 @@
33

44
namespace TabbedPageDemo
55
{
6-
public class MonkeyDataModel
7-
{
8-
public string Name { set; get; }
9-
10-
public string Family { set; get; }
11-
12-
public string Subfamily { set; get; }
13-
14-
public string Tribe { set; get; }
15-
16-
public string Genus { set; get; }
17-
18-
public string PhotoUrl { set; get; }
19-
20-
public static IList<MonkeyDataModel> All { set; get; }
21-
22-
static MonkeyDataModel ()
23-
{
24-
All = new ObservableCollection<MonkeyDataModel> {
25-
new MonkeyDataModel {
26-
Name = "Chimpanzee",
27-
Family = "Hominidae",
28-
Subfamily = "Homininae",
29-
Tribe = "Panini",
30-
Genus = "Pan",
31-
PhotoUrl = "http://upload.wikimedia.org/wikipedia/commons/thumb/6/62/Schimpanse_Zoo_Leipzig.jpg/640px-Schimpanse_Zoo_Leipzig.jpg"
32-
},
33-
new MonkeyDataModel {
34-
Name = "Orangutan",
35-
Family = "Hominidae",
36-
Subfamily = "Ponginae",
37-
Genus = "Pongo",
38-
PhotoUrl = "http://upload.wikimedia.org/wikipedia/commons/b/be/Orang_Utan%2C_Semenggok_Forest_Reserve%2C_Sarawak%2C_Borneo%2C_Malaysia.JPG"
39-
},
40-
new MonkeyDataModel {
41-
Name = "Tamarin",
42-
Family = "Callitrichidae",
43-
Genus = "Saguinus",
44-
PhotoUrl = "http://upload.wikimedia.org/wikipedia/commons/thumb/8/85/Tamarin_portrait_2_edit3.jpg/640px-Tamarin_portrait_2_edit3.jpg"
45-
}
46-
};
47-
}
48-
}
6+
public class MonkeyDataModel
7+
{
8+
public string Name { set; get; }
9+
10+
public string Family { set; get; }
11+
12+
public string Subfamily { set; get; }
13+
14+
public string Tribe { set; get; }
15+
16+
public string Genus { set; get; }
17+
18+
public string PhotoUrl { set; get; }
19+
20+
public static IList<MonkeyDataModel> All { set; get; }
21+
22+
static MonkeyDataModel()
23+
{
24+
All = new ObservableCollection<MonkeyDataModel>
25+
{
26+
new MonkeyDataModel
27+
{
28+
Name = "Chimpanzee",
29+
Family = "Hominidae",
30+
Subfamily = "Homininae",
31+
Tribe = "Panini",
32+
Genus = "Pan",
33+
PhotoUrl = "http://upload.wikimedia.org/wikipedia/commons/thumb/6/62/Schimpanse_Zoo_Leipzig.jpg/640px-Schimpanse_Zoo_Leipzig.jpg"
34+
},
35+
new MonkeyDataModel
36+
{
37+
Name = "Orangutan",
38+
Family = "Hominidae",
39+
Subfamily = "Ponginae",
40+
Genus = "Pongo",
41+
PhotoUrl = "http://upload.wikimedia.org/wikipedia/commons/b/be/Orang_Utan%2C_Semenggok_Forest_Reserve%2C_Sarawak%2C_Borneo%2C_Malaysia.JPG"
42+
},
43+
new MonkeyDataModel
44+
{
45+
Name = "Tamarin",
46+
Family = "Callitrichidae",
47+
Genus = "Saguinus",
48+
PhotoUrl = "http://upload.wikimedia.org/wikipedia/commons/thumb/8/85/Tamarin_portrait_2_edit3.jpg/640px-Tamarin_portrait_2_edit3.jpg"
49+
}
50+
};
51+
}
52+
}
4953
}

Navigation/TabbedPage/TabbedPageDemo/TabbedPageDemo/NonNullToBooleanConverter.cs

100755100644
+15-14
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,21 @@
44

55
namespace TabbedPageDemo
66
{
7-
class NonNullToBooleanConverter : IValueConverter
8-
{
9-
public object Convert (object value, Type targetType, object parameter, CultureInfo culture)
10-
{
11-
if (value is string) {
12-
return !string.IsNullOrEmpty ((string)value);
13-
}
7+
class NonNullToBooleanConverter : IValueConverter
8+
{
9+
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
10+
{
11+
if (value is string)
12+
{
13+
return !string.IsNullOrEmpty((string)value);
14+
}
1415

15-
return value != null;
16-
}
16+
return value != null;
17+
}
1718

18-
public object ConvertBack (object value, Type targetType, object parameter, CultureInfo culture)
19-
{
20-
return null;
21-
}
22-
}
19+
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
20+
{
21+
return null;
22+
}
23+
}
2324
}

Navigation/TabbedPage/TabbedPageDemo/TabbedPageDemo/TabbedPageDemoPage.xaml

100755100644
+4-5
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
<TabbedPage xmlns="http://xamarin.com/schemas/2014/forms"
33
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
44
xmlns:local="clr-namespace:TabbedPageDemo;assembly=TabbedPageDemo"
5-
x:Class="TabbedPageDemo.TabbedPageDemoPage">
5+
x:Class="TabbedPageDemo.TabbedPageDemoPage"
6+
ItemsSource="{x:Static local:MonkeyDataModel.All}">
67
<TabbedPage.Resources>
78
<ResourceDictionary>
89
<local:NonNullToBooleanConverter x:Key="booleanConverter" />
@@ -26,16 +27,14 @@
2627
Font="Bold,Medium" />
2728
</StackLayout>
2829
<StackLayout Orientation="Horizontal"
29-
IsVisible="{Binding Subfamily,
30-
Converter={StaticResource booleanConverter}}">
30+
IsVisible="{Binding Subfamily, Converter={StaticResource booleanConverter}}">
3131
<Label Text="Subfamily:"
3232
HorizontalOptions="FillAndExpand" />
3333
<Label Text="{Binding Subfamily}"
3434
Font="Bold,Medium" />
3535
</StackLayout>
3636
<StackLayout Orientation="Horizontal"
37-
IsVisible="{Binding Tribe,
38-
Converter={StaticResource booleanConverter}}">
37+
IsVisible="{Binding Tribe, Converter={StaticResource booleanConverter}}">
3938
<Label Text="Tribe:"
4039
HorizontalOptions="FillAndExpand" />
4140
<Label Text="{Binding Tribe}"

Navigation/TabbedPage/TabbedPageDemo/TabbedPageDemo/TabbedPageDemoPage.xaml.cs

100755100644
-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ public partial class TabbedPageDemoPage : TabbedPage
77
public TabbedPageDemoPage ()
88
{
99
InitializeComponent ();
10-
ItemsSource = MonkeyDataModel.All;
1110
}
1211
}
1312
}

Navigation/TabbedPage/TabbedPageDemo/TabbedPageDemo/TabbedPageDemoPageCS.cs

100755100644
+106-87
Original file line numberDiff line numberDiff line change
@@ -2,103 +2,122 @@
22

33
namespace TabbedPageDemo
44
{
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();
1010

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");
1820

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");
2123

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");
2730

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");
3337

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");
3944

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");
4551

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));
5462

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));
6373

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+
}
92111

93-
}
94-
}
95-
};
96-
contentPage.SetBinding (TitleProperty, "Name");
112+
}
113+
}
114+
};
115+
contentPage.SetBinding(TitleProperty, "Name");
97116

98-
return contentPage;
99-
});
117+
return contentPage;
118+
});
100119

101-
ItemsSource = MonkeyDataModel.All;
102-
}
103-
}
120+
ItemsSource = MonkeyDataModel.All;
121+
}
122+
}
104123
}

0 commit comments

Comments
 (0)