Skip to content

Commit a527bc0

Browse files
committed
Sample app updates.
1 parent eb36931 commit a527bc0

File tree

2 files changed

+18
-34
lines changed

2 files changed

+18
-34
lines changed

Source/Plugin.Badge.UWP/BadgedTabbedPageRenderer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ protected override void OnElementChanged(VisualElementChangedEventArgs e)
1515
foreach (var tab in Element.Children)
1616
{
1717
tab.PropertyChanged -= Tab_PropertyChanged;
18-
tab.PropertyChanged += Tab_PropertyChanged;
18+
tab.PropertyChanged += Tab_PropertyChanged;
1919
}
2020
}
2121

Source/Sample/Plugin.Badge.Sample/Plugin.Badge.Sample.cs

Lines changed: 17 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -34,33 +34,17 @@ public App()
3434
MainPage = new NavigationPage(_tabbedPage);
3535
}
3636

37-
private ContentPage CreateTab3()
37+
private ContentPage CreateTab2()
3838
{
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;
5943
}
6044

61-
private ContentPage CreateTab2()
45+
private ContentPage CreateTab3()
6246
{
63-
var tab2 = new ContentPage
47+
var tab3 = new ContentPage
6448
{
6549
Title = "Tab2",
6650
Content = new StackLayout
@@ -87,9 +71,9 @@ private ContentPage CreateTab2()
8771
}
8872
};
8973

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;
9377
}
9478

9579
private ContentPage CreateTab1()
@@ -157,8 +141,8 @@ private ContentPage CreateTab1()
157141
grid = new Grid { RowSpacing = 0 };
158142
grid.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto });
159143
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 });
162146
grid.ColumnDefinitions.Add(new ColumnDefinition());
163147
grid.ColumnDefinitions.Add(new ColumnDefinition());
164148

@@ -180,22 +164,22 @@ private ContentPage CreateTab1()
180164
rightStepper.SetBinding(Stepper.ValueProperty, nameof(Tab1ViewModel.MarginRight), BindingMode.TwoWay);
181165
var rightMarginLabel = new Label();
182166
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);
185169

186170
var bottomStepper = new Stepper { Increment = 1, Minimum = -50, Maximum = 50 };
187171
bottomStepper.SetBinding(Stepper.ValueProperty, nameof(Tab1ViewModel.MarginBottom), BindingMode.TwoWay);
188172
var bottomMarginLabel = new Label();
189173
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);
192176

193177
tab1Layout.Children.Add(grid);
194178

195179
var tab1 = new ContentPage
196180
{
197181
Title = "Tab1",
198-
Content = tab1Layout
182+
Content = new ScrollView() { Content = tab1Layout }
199183
};
200184

201185
tab1.SetBinding(TabBadge.BadgeTextProperty, nameof(Tab1ViewModel.Count));

0 commit comments

Comments
 (0)