Пример #1
0
        public ContactDetailsTabView(Contact contact)
        {
            if (contact != null)
            {
                this.Title = contact.DisplayName;
            } else {
                this.Title = "New Contact";
            }


            viewModel = new ContactDetailsViewModel(contact) { Navigation = Navigation };

            this.Children.Add(new ContactDetailsView(viewModel) { Title = "Contact" });


            this.Children.Add(new ContactMapView(viewModel) { Title = "Map" });


            //ToolbarItems.Add(new ToolbarItem("Done", Device.OnPlatform<string>(null, null, "done.png"),  async () =>
            ToolbarItems.Add(new ToolbarItem("Done", "save.png",  async () =>
            {
                var confirmed = await DisplayAlert("Unsaved Changes", "Save changes?", "Save", "Discard");
                if (confirmed)
                {
                    viewModel.SaveContactCommand.Execute(null);
                }
                else
                {
                    viewModel.GoBack();
                    System.Diagnostics.Debug.WriteLine("ContactDetailsTabView - cancel changes!");
                }
            }));

        } //end ctor
Пример #2
0
        public ContactMapView(ContactDetailsViewModel vm)
        {
            this.Title = "Map";
            this.Icon = "map.png";

            this.BindingContext = vm;


            ViewModel.PropertyChanged += (sender, args) =>
            {
                if (args.PropertyName == "Contact")
                    MakeMap();
            };


            map = new Map()
            {
                IsShowingUser = true
            };

            this.MakeMap();

            var stack = new StackLayout { Spacing = 0 };

            map.VerticalOptions = LayoutOptions.FillAndExpand;
            map.HeightRequest = 100;
            map.WidthRequest = 960;

            stack.Children.Add(map);
            Content = stack;
        }
		public ContactDetailsView (ContactDetailsViewModel viewModel)
		{
				InitializeComponent ();

				SetBinding(Page.TitleProperty, new Binding("Title"));
				SetBinding(Page.IconProperty, new Binding("Icon"));

				this.BindingContext = viewModel;

		} //end ctor