Beispiel #1
0
        public static async Task Main(string[] args)
        {
            SetupSerilog();

            DefaultTypeMap.MatchNamesWithUnderscores = true;

            MonkeyHelper.SetupCache();

            await CreateHostBuilder(args)
            .Build()
            .RunAsync();
        }
Beispiel #2
0
        public MonkeysPage()
        {
            Title   = "Monkeys";
            Monkeys = new ObservableCollection <Monkey> ();

            var list = new ListView();

            list.ItemsSource = Monkeys;

            var cell = new DataTemplate(typeof(ImageCell));

            cell.SetBinding(TextCell.TextProperty, "Name");
            cell.SetBinding(TextCell.DetailProperty, "Location");
            cell.SetBinding(ImageCell.ImageSourceProperty, "Image");

            list.ItemTemplate = cell;

            list.ItemTapped += (sender, args) =>
            {
                var monkey = args.Item as Monkey;
                if (monkey == null)
                {
                    return;
                }

                Navigation.PushAsync(new DetailsPage(monkey));
                // Reset the selected item
                list.SelectedItem = null;
            };

            var addMonkeyButton = new Button {
                Text = "Add Monkey"
            };

            addMonkeyButton.Clicked += (sender, e) => {
                Monkeys.Add(MonkeyHelper.GetRandomMonkey());
            };

            var stack = new StackLayout {
                Children = { list, addMonkeyButton }
            };

            Content = stack;
        }