public class MenuSample : IExample
{
private static readonly int itemCount = 20;
+ private MenuItem[] menuItems = new MenuItem[itemCount];
public void Activate()
{
};
navigator.Push(page);
- MenuItem[] menuItems = new MenuItem[itemCount];
-
for (int i = 0; i < itemCount; i++)
{
menuItems[i] = new MenuItem() { Text = "Menu" + (i + 1) };
public void Deactivate()
{
+ for (int i = 0; i < itemCount; i++)
+ {
+ if (menuItems[i] != null)
+ {
+ menuItems[i].Dispose();
+ menuItems[i] = null;
+ }
+ }
+
var window = NUIApplication.GetDefaultWindow();
var navigator = window.GetDefaultNavigator();
var newPageCount = window.GetDefaultNavigator().PageCount;
utilitySwitch[i].ApplyStyle(utilitySt);
utilitySwitch[i].Size = new Size(96, 60);
utilitySwitch[i].Margin = new Extents(100, 0, 20, 0);
+#if PROFILE_MOBILE
utilitySwitch[i].Feedback = true;
+#endif
parentView[2].Add(utilitySwitch[i]);
}
for (i = 0; i < 4; i++)
familySwitch[i] = new Switch();
familySwitch[i].ApplyStyle(familySt);
familySwitch[i].Size = new Size(96, 60);
+#if PROFILE_MOBILE
familySwitch[i].Feedback = true;
+#endif
parentView[2].Add(familySwitch[i]);
}
for (i = 0; i < 4; i++)
foodSwitch[i] = new Switch();
foodSwitch[i].ApplyStyle(foodSt);
foodSwitch[i].Size = new Size(96, 60);
+#if PROFILE_MOBILE
foodSwitch[i].Feedback = true;
+#endif
parentView[2].Add(foodSwitch[i]);
}
for (i = 0; i < 4; i++)
kitchenSwitch[i] = new Switch();
kitchenSwitch[i].ApplyStyle(kitchenSt);
kitchenSwitch[i].Size = new Size(96, 60);
+#if PROFILE_MOBILE
kitchenSwitch[i].Feedback = true;
+#endif
parentView[2].Add(kitchenSwitch[i]);
}
utilitySwitch2[i] = new Switch();
utilitySwitch2[i].ApplyStyle(utilitySt);
utilitySwitch2[i].Size = new Size(96, 60);
+#if PROFILE_MOBILE
utilitySwitch2[i].Feedback = true;
+#endif
parentView[2].Add(utilitySwitch2[i]);
}
for (i = 0; i < 4; i++)
familySwitch2[i] = new Switch();
familySwitch2[i].ApplyStyle(familySt);
familySwitch2[i].Size = new Size(96, 60);
+#if PROFILE_MOBILE
familySwitch2[i].Feedback = true;
+#endif
parentView[2].Add(familySwitch2[i]);
}
for (i = 0; i < 4; i++)
foodSwitch2[i] = new Switch();
foodSwitch2[i].ApplyStyle(foodSt);
foodSwitch2[i].Size = new Size(96, 60);
+#if PROFILE_MOBILE
foodSwitch2[i].Feedback = true;
+#endif
parentView[2].Add(foodSwitch2[i]);
}
for (i = 0; i < 4; i++)
kitchenSwitch2[i] = new Switch();
kitchenSwitch2[i].ApplyStyle(kitchenSt);
kitchenSwitch2[i].Size = new Size(96, 60);
+#if PROFILE_MOBILE
kitchenSwitch2[i].Feedback = true;
+#endif
parentView[2].Add(kitchenSwitch2[i]);
}
internal class MenuExample : ContentPage, IExample
{
private View rootContent;
+ private MenuItem[] menuItem = new MenuItem[4];
+
public void Activate()
{
}
public void Deactivate()
{
+ for (int i = 0; i < 4; i++)
+ {
+ if (menuItem[i] != null)
+ {
+ menuItem[i].Dispose();
+ menuItem[i] = null;
+ }
+ }
+
+ if (rootContent != null)
+ {
+ rootContent.Dispose();
+ rootContent = null;
+ }
}
/// Modify this method for adding other examples.
rootContent.Add(page);
- var menuItem = new MenuItem() { Text = "Menu" };
- menuItem.SelectedChanged += (object sender, SelectedChangedEventArgs args) =>
+ for (int i = 0; i < 4; i++)
{
- global::System.Console.WriteLine($"1st MenuItem's IsSelected is changed to {args.IsSelected}.");
- };
-
- var menuItem2 = new MenuItem() { Text = "Menu2" };
- menuItem2.SelectedChanged += (object sender, SelectedChangedEventArgs args) =>
- {
- global::System.Console.WriteLine($"2nd MenuItem's IsSelected is changed to {args.IsSelected}.");
- };
-
- var menuItem3 = new MenuItem() { Text = "Menu3" };
- menuItem3.SelectedChanged += (object sender, SelectedChangedEventArgs args) =>
- {
- global::System.Console.WriteLine($"3rd MenuItem's IsSelected is changed to {args.IsSelected}.");
- };
-
- var menuItem4 = new MenuItem() { Text = "Menu4" };
- menuItem4.SelectedChanged += (object sender, SelectedChangedEventArgs args) =>
- {
- global::System.Console.WriteLine($"4th MenuItem's IsSelected is changed to {args.IsSelected}.");
- };
+ menuItem[i] = new MenuItem();
+ menuItem[i].Text = "Menu" + (i + 1);
+ menuItem[i].SelectedChanged += (object sender, SelectedChangedEventArgs args) =>
+ {
+ var item = sender as MenuItem;
+ global::System.Console.WriteLine(item.Text + $"'s IsSelected is changed to {args.IsSelected}.");
+ };
+ }
moreButton.Clicked += (object sender, ClickedEventArgs args) =>
{
Anchor = moreButton,
HorizontalPositionToAnchor = Menu.RelativePosition.Center,
VerticalPositionToAnchor = Menu.RelativePosition.End,
- Items = new MenuItem[] { menuItem, menuItem2, menuItem3, menuItem4 },
+ Items = new MenuItem[] { menuItem[0], menuItem[1], menuItem[2], menuItem[3] },
};
menu.Post();
};
colorView.WidthSpecification = (isHorizontal? 200 : LayoutParamPolicies.MatchParent);
colorView.HeightSpecification = (isHorizontal? LayoutParamPolicies.MatchParent : 200);
colorView.BackgroundColor = new Color((float)rnd.Next(256)/256f, (float)rnd.Next(256)/256f, (float)rnd.Next(256)/256f, 1);
+ colorView.Focusable = true;
+ colorView.FocusableInTouch = true;
scrollView.Add(colorView);
}
Content = scrollView;
}
}
-}
\ No newline at end of file
+}
};
item.Label.SetBinding(TextLabel.TextProperty, "Direction");
item.Label.HorizontalAlignment = HorizontalAlignment.Begin;
+ item.Focusable = true;
+ item.FocusableInTouch = true;
return item;
}),
ScrollingDirection = ScrollableBase.Direction.Vertical,
switchTest[i].ApplyStyle(styleTest);
switchTest[i].Size = new Size(200, 100);
switchTest[i].Margin = new Extents(10, 10, 10, 10);
+#if PROFILE_MOBILE
switchTest[i].Feedback = true;
+#endif
rootContent.Add(switchTest[i]);
}
switchTest[2].IsEnabled = false;