using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Xamarin.Forms; using Xamarin.Forms.Xaml; namespace InABox.Mobile { [XamlCompilation(XamlCompilationOptions.Compile)] public partial class MobileMenuButtonMenu { public IList Items => _viewModel.Items; public IList VisibleItems => _viewModel.VisibleItems; public MobileMenuButtonMenu() { InitializeComponent(); } private void TapGestureRecognizer_OnTapped(object sender, EventArgs e) { if ((sender as Label)?.BindingContext is MobileMenuItem item) item.DoClicked(); } private void _viewModel_OnLayoutChanged(object sender, MobileMenuButtonLayoutChangedEventArgs args) { _menu.RowDefinitions.Clear(); for (int i=0; i< args.RowCount; i++) _menu.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto}); } public event EventHandler ItemClicked; private void _viewModel_OnItemClicked(object sender, EventArgs e) { ItemClicked?.Invoke(this, EventArgs.Empty); } } }