public void NotifyItemSelected(HMenuItemView item) { foreach (HMenuItemView child in slMenuItems.Children) { child.Selected = false; if (child.Text == item.Text) { child.Selected = true; if (ItemSelectd != null) { ItemSelectd(ItemSelectd, new HMenuItemSelectdEventArgs(item.Text, item.Value)); } } } }
private static void OnItemsPropertyChanged(BindableObject bindable, object oldValue, object newValue) { var thisView = bindable as HMenuView; var category = newValue as IList <HMenuItem>; if (category != null) { thisView.slMenuItems.Children.Clear(); foreach (var item in category) { var horizontalMenuItemView = new HMenuItemView() { Text = item.Text, Value = item.Value.ToString(), Selected = item.Selected, }; horizontalMenuItemView.ItemSelected += (sender, e) => { thisView.NotifyItemSelected(horizontalMenuItemView); }; thisView.slMenuItems.Children.Add(horizontalMenuItemView); } } }