@@ -34,33 +34,17 @@ public App()
34
34
MainPage = new NavigationPage ( _tabbedPage ) ;
35
35
}
36
36
37
- private ContentPage CreateTab3 ( )
37
+ private ContentPage CreateTab2 ( )
38
38
{
39
- var tab3 = new ContentPage
40
- {
41
- Title = "Tab3" ,
42
- Icon = "tabicon.png" ,
43
- Content = new StackLayout
44
- {
45
- VerticalOptions = LayoutOptions . Center ,
46
- Children =
47
- {
48
- new Label
49
- {
50
- HorizontalTextAlignment = TextAlignment . Center ,
51
- Text = "Welcome to Xamarin Forms Tab3!"
52
- }
53
- }
54
- }
55
- } ;
56
-
57
- TabBadge . SetBadgeText ( tab3 , "X" ) ;
58
- return tab3 ;
39
+ var tab2 = CreateTab1 ( ) ;
40
+ tab2 . Icon = "tabicon.png" ;
41
+ ( tab2 . BindingContext as Tab1ViewModel ) . CountValue = 1 ;
42
+ return tab2 ;
59
43
}
60
44
61
- private ContentPage CreateTab2 ( )
45
+ private ContentPage CreateTab3 ( )
62
46
{
63
- var tab2 = new ContentPage
47
+ var tab3 = new ContentPage
64
48
{
65
49
Title = "Tab2" ,
66
50
Content = new StackLayout
@@ -87,9 +71,9 @@ private ContentPage CreateTab2()
87
71
}
88
72
} ;
89
73
90
- TabBadge . SetBadgeText ( tab2 , "1+" ) ;
91
- TabBadge . SetBadgeColor ( tab2 , Color . FromHex ( "#A0FFA500" ) ) ;
92
- return tab2 ;
74
+ TabBadge . SetBadgeText ( tab3 , "1+" ) ;
75
+ TabBadge . SetBadgeColor ( tab3 , Color . FromHex ( "#A0FFA500" ) ) ;
76
+ return tab3 ;
93
77
}
94
78
95
79
private ContentPage CreateTab1 ( )
@@ -157,8 +141,8 @@ private ContentPage CreateTab1()
157
141
grid = new Grid { RowSpacing = 0 } ;
158
142
grid . RowDefinitions . Add ( new RowDefinition ( ) { Height = GridLength . Auto } ) ;
159
143
grid . RowDefinitions . Add ( new RowDefinition ( ) { Height = GridLength . Auto } ) ;
160
- grid . ColumnDefinitions . Add ( new ColumnDefinition ( ) ) ;
161
- grid . ColumnDefinitions . Add ( new ColumnDefinition ( ) ) ;
144
+ grid . RowDefinitions . Add ( new RowDefinition ( ) { Height = GridLength . Auto } ) ;
145
+ grid . RowDefinitions . Add ( new RowDefinition ( ) { Height = GridLength . Auto } ) ;
162
146
grid . ColumnDefinitions . Add ( new ColumnDefinition ( ) ) ;
163
147
grid . ColumnDefinitions . Add ( new ColumnDefinition ( ) ) ;
164
148
@@ -180,22 +164,22 @@ private ContentPage CreateTab1()
180
164
rightStepper . SetBinding ( Stepper . ValueProperty , nameof ( Tab1ViewModel . MarginRight ) , BindingMode . TwoWay ) ;
181
165
var rightMarginLabel = new Label ( ) ;
182
166
rightMarginLabel . SetBinding ( Label . TextProperty , nameof ( Tab1ViewModel . MarginRight ) , stringFormat : "Right: {0}" ) ;
183
- grid . Children . Add ( rightMarginLabel , 2 , 0 ) ;
184
- grid . Children . Add ( rightStepper , 2 , 1 ) ;
167
+ grid . Children . Add ( rightMarginLabel , 0 , 2 ) ;
168
+ grid . Children . Add ( rightStepper , 0 , 3 ) ;
185
169
186
170
var bottomStepper = new Stepper { Increment = 1 , Minimum = - 50 , Maximum = 50 } ;
187
171
bottomStepper . SetBinding ( Stepper . ValueProperty , nameof ( Tab1ViewModel . MarginBottom ) , BindingMode . TwoWay ) ;
188
172
var bottomMarginLabel = new Label ( ) ;
189
173
bottomMarginLabel . SetBinding ( Label . TextProperty , nameof ( Tab1ViewModel . MarginBottom ) , stringFormat : "Bottom: {0}" ) ;
190
- grid . Children . Add ( bottomMarginLabel , 3 , 0 ) ;
191
- grid . Children . Add ( bottomStepper , 3 , 1 ) ;
174
+ grid . Children . Add ( bottomMarginLabel , 1 , 2 ) ;
175
+ grid . Children . Add ( bottomStepper , 1 , 3 ) ;
192
176
193
177
tab1Layout . Children . Add ( grid ) ;
194
178
195
179
var tab1 = new ContentPage
196
180
{
197
181
Title = "Tab1" ,
198
- Content = tab1Layout
182
+ Content = new ScrollView ( ) { Content = tab1Layout }
199
183
} ;
200
184
201
185
tab1 . SetBinding ( TabBadge . BadgeTextProperty , nameof ( Tab1ViewModel . Count ) ) ;
0 commit comments