public App() { Picker pickerArrival = new Picker (); pickerArrival.Items.Add ("Android"); pickerArrival.Items.Add ("iOS"); pickerArrival.Items.Add ("Windows Phone"); Button bt = new Button { Text = "Select OS", }; bt.Clicked += (e, sender) => { Console.WriteLine ("Selected item: " + pickerArrival.Items [pickerArrival.SelectedIndex] + " - index: " + pickerArrival.SelectedIndex); }; // The root page of your application MainPage = new ContentPage { Content = new StackLayout { VerticalOptions = LayoutOptions.Center, Children = { pickerArrival, bt } } }; }
ContentPage CreatePage (Color backgroundColor) { _index++; var button = new Button () { Text = "next Page", }; button.Clicked += (sender, e) => { var page = CreatePage (Color.Green); _navigationPage.PushAsync (page); }; var contentPage = new ContentPage () { Content = new StackLayout () { BackgroundColor = backgroundColor, VerticalOptions = LayoutOptions.Fill, Children = { new Label () { Text = "page " + _index, }, } } }; return contentPage; }
public void Navigate_ToMasterDetailPage_ViewModelHasINavigationAware() { var navigationService = new PageNavigationServiceMock(_container); var rootPage = new Xamarin.Forms.ContentPage(); ((IPageAware)navigationService).Page = rootPage; navigationService.Navigate("MasterDetailPage"); Assert.True(rootPage.Navigation.ModalStack.Count == 1); var mdPage = rootPage.Navigation.ModalStack[0] as MasterDetailPage; Assert.NotNull(mdPage); var viewModel = mdPage.BindingContext as MasterDetailPageMockViewModel; Assert.NotNull(viewModel); Assert.True(viewModel.OnNavigatedToCalled); //Assert.NotNull(mdPage.Detail); //Assert.IsType(typeof(ContentPageMock), mdPage.Detail); //var childViewModel = mdPage.Detail.BindingContext as ContentPageMockViewModel; //Assert.NotNull(childViewModel); //Assert.True(childViewModel.OnNavigatedToCalled); }
public App() { var entry = new CustomEntry { Text = "Welcome to Xamarin Forms!", BorderWidth = 5, }; var slider = new Slider { Minimum = 0f, Maximum = 20f }; entry.BindingContext = slider; entry.SetBinding(CustomEntry.BorderWidthProperty, new Binding("Value", BindingMode.OneWay)); // The root page of your application MainPage = new ContentPage { Content = new StackLayout { VerticalOptions = LayoutOptions.Center, Children = { entry, slider } } }; }
public App() { var mainLabel = new Label { XAlign = TextAlignment.Center, Text = "Starting test run..." }; var testsLabel = new Label { XAlign = TextAlignment.Center, Text = "" }; // The root page of your application MainPage = new ContentPage { Content = new StackLayout { VerticalOptions = LayoutOptions.Center, Children = { mainLabel, testsLabel } } }; try { runner = new XFormsPortableRunner(mainLabel, testsLabel, Xamarin.Forms.Device.BeginInvokeOnMainThread); } catch(Exception e) { testsLabel.Text += e.ToString(); } TestSdk(testsLabel); }
public App() { //ElementsCreation; InitializeElements(); // The root page of your application MainPage = new ContentPage { Content = new StackLayout { HorizontalOptions = LayoutOptions.StartAndExpand, Orientation = StackOrientation.Vertical, Children = { billLabel, billEntry, tipPersentageLabel, tipPersentageStepper, numberOfPeopleLabel, numberOfPeopleStepper, calculateTipButton, tipAmountTextLabel, tipAmountValueLabel, totalAmountTextLabel, totalAmountValueLabel, amountPerPersonTextLabel, amountPerPersonValueLabel } } }; }
private static XF.ContentPage GetErrorPageForException(Exception exception) { var errorPage = new XF.ContentPage() { Title = "Unhandled exception", Content = new XF.StackLayout { Padding = 10, Children = { new XF.Label { FontAttributes = XF.FontAttributes.Bold, FontSize = XF.Device.GetNamedSize(XF.NamedSize.Large, typeof(XF.Label)), Text = "Unhandled exception", }, new XF.Label { Text = exception?.Message, }, new XF.ScrollView { Content = new XF.Label { FontSize = XF.Device.GetNamedSize(XF.NamedSize.Small, typeof(XF.Label)), Text = exception?.StackTrace, }, }, }, }, }; return(errorPage); }
public static Page GetMainPage() { //Se crea un objeto etiqueta //Label label = new Label(); //Se modifican sus propiedades //Texto //label.Text = "Cámbiame"; //Color del texto //label.TextColor = Color.Blue; //Alineación vertical (YAlign). Para la alineación horizontal, usar XAlign //label.YAlign = TextAlignment.Center; //El mismo código usando inicializador de objetos Label label = new Label { Text = "NAVA_A_JOSE_U1_ACT4_PROG_DISP_MOVILES", TextColor = Color.Green, YAlign = TextAlignment.Center }; //Se crea una página y se le asigna como contenido la eqtiqueta que se creó ContentPage contentPage = new ContentPage(); contentPage.Content = label; return contentPage; }
public async Task ExecuteLoadStatsCommand() { if (IsBusy) return; IsBusy = true; try { var adminManager = new AdminManager(Settings.AccessToken); Names.Clear(); foreach(var name in await adminManager.PopularNames()) { Names.Add(name); } } catch (Exception ex) { var page = new ContentPage(); page.DisplayAlert("Error", "Unable to load.", "OK"); ; } finally { IsBusy = false; } }
public App() { var lcb = new LegalCheckbox(); // The root page of your application var CheckButton = new Button(); var result = new Label(); CheckButton.Clicked += (sender, e) => { if (lcb.Checked) { result.Text = "Its Checked"; } else { result.Text = "Not Checked"; } }; MainPage = new ContentPage { Content = new StackLayout { VerticalOptions = LayoutOptions.Center, Children = { lcb, CheckButton, result } } }; }
public App() { //var assembly = typeof(App).GetTypeInfo().Assembly; //XamSvg.Shared.Config.ResourceAssembly = assembly; //XamSvg.Shared.Config.ResourceAssemblies.Add(typeof(RatingView).GetTypeInfo().Assembly); //XamSvg.Shared.Config.ResourceAssemblies.Add(typeof(App).GetTypeInfo().Assembly); //XamSvg.Shared.Config.ResourceAssemblies = new List<Assembly> //{ // typeof(RatingView).GetTypeInfo().Assembly, // typeof (App).GetTypeInfo().Assembly //}; //XamSvg.Shared.Config.ResourceAssembly = typeof(RatingView).GetTypeInfo().Assembly; InitializeComponent(); // The navigator be in charge of knowing how to bring up a Page when asked to bring up it's corresponding ViewModel var navigator = new Navigator(this); var navigationDestinations = CreateDestinations(navigator); navigator.Initialize(navigationDestinations); //navigator.Show<DemoScreenSizeViewModel>(); MainPage = new Xamarin.Forms.ContentPage { Content = new DemoScreenSizeView { BindingContext = new DemoScreenSizeViewModel(navigator) } }; //MainPage = new Xamarin.Forms.ContentPage() { Content = new Xamarin.Forms.Label() { Text = "Hello World", TextColor = Color.Red} }; //navigator.Show<MainViewModel>(); }
public async Task ExecuteArticleCommand() { if (IsBusy) return; IsBusy = true; LoadArticleCommand.ChangeCanExecute(); try { GetArticleHtmlandUpdate(); Expand = " CLOSE ▲"; OnPropertyChanged("Expand"); } catch (Exception ex) { var page = new ContentPage(); page.DisplayAlert("Error", "Unable to load Article Content.", "OK"); } IsBusy = false; LoadArticleCommand.ChangeCanExecute(); }
public App () { var cards = new CardData (); var cardstack = new StackLayout { Spacing = 15, Padding = new Thickness (10), VerticalOptions = LayoutOptions.StartAndExpand, }; foreach (var card in cards) { cardstack.Children.Add (new CardView (card)); } var page = new ContentPage { Title = "Activity", BackgroundColor = Color.White, Content = new ScrollView () { Content = cardstack } }; MainPage = new NavigationPage (page) { BarBackgroundColor = StyleKit.BarBackgroundColor, BarTextColor = Color.White }; }
public App() { InitializeComponent(); var label = new Label(); var button = new Button() { Text = "送信", }; conn = new HubConnection("http://localhost:5000"); proxy = conn.CreateHubProxy("hello"); proxy.On<string>("helloWorld", x => { label.Text = x; }); conn.Start(); button.Clicked += OnClick; var stack = new StackLayout() { Orientation = StackOrientation.Vertical, }; stack.Children.Add(label); stack.Children.Add(button); MainPage = new ContentPage() { Content = stack, }; }
public ApplicationProviderMock() { MainPage = new ContentPage() { Title = "MainPage" }; }
public async Task ExecuteLoadStatsCommand() { if (IsBusy) return; IsBusy = true; try { var adminManager = new AdminManager(Settings.AccessToken); RegDates.Clear(); foreach(var reg in await adminManager.TotalRegistrations()) { RegDates.Add(new MyRegDate { Title = new DateTime(reg.Year, reg.Month, reg.Day).ToString("D"), Detail = reg.Total.ToString() }); } } catch (Exception ex) { var page = new ContentPage(); page.DisplayAlert("Error", "Unable to load.", "OK"); ; } finally { IsBusy = false; } }
public App() { Button showInfo = new Button { Text = "Info" }; showInfo.Clicked += (s, e) => ShowToast(ToastNotificationType.Info); Button showSuccess = new Button { Text = "Success" }; showSuccess.Clicked += (s, e) => ShowToast(ToastNotificationType.Success); Button showWarning = new Button { Text = "Warning" }; showWarning.Clicked += (s, e) => ShowToast(ToastNotificationType.Warning); Button showError = new Button { Text = "Error" }; showError.Clicked += (s, e) => ShowToast(ToastNotificationType.Error); // The root page of your application MainPage = new ContentPage { Content = new StackLayout { VerticalOptions = LayoutOptions.Center, Children = { showInfo, showSuccess, showWarning, showError } } }; }
public App() { NavigationPage _nav = null; var listView = new ListView (); listView.ItemsSource = _builder.BuildSamples (); listView.ItemTemplate = new DataTemplate (typeof(TextCell)); listView.ItemTemplate.SetBinding (TextCell.TextProperty, "Name"); listView.ItemTemplate.SetBinding (TextCell.DetailProperty, "Name"); listView.ItemSelected += async (sender, e) => { var sample = (ViewSample)e.SelectedItem; var samplePage = new ViewSamplePage(sample); await _nav.PushAsync(samplePage); }; var root = new ContentPage { Title = "Common Controls", Content = listView }; _nav = new NavigationPage (root); // The root page of your application MainPage = _nav; }
protected void CreateMenuPage(string menuPageTitle) { var _menuPage = new ContentPage (); _menuPage.Title = menuPageTitle; var listView = new ListView(); listView.ItemsSource = new string[] { "Contacts", "Quotes", "Modal Demo" }; listView.ItemSelected += async (sender, args) => { switch ((string)args.SelectedItem) { case "Contacts": _tabbedNavigationPage.CurrentPage = _contactsPage; break; case "Quotes": _tabbedNavigationPage.CurrentPage = _quotesPage; break; case "Modal Demo": var modalPage = FreshPageModelResolver.ResolvePageModel<ModalPageModel>(); await PushPage(modalPage, null, true); break; default: break; } IsPresented = false; }; _menuPage.Content = listView; Master = new NavigationPage(_menuPage) { Title = "Menu" }; }
public App() { // The root page of your application MainPage = new ContentPage { }; }
public App() { // The root page of your application MainPage = new ContentPage { Content = new StackLayout { VerticalOptions = LayoutOptions.Center, Children = { new Label { XAlign = TextAlignment.Center, Text = "Image Container:" }, new ContentView{ BackgroundColor = Color.Gray, Padding = 25, HeightRequest = 200, Content = new ImageViewer{ Source = ImageSource.FromStream(() => { var assembly = this.GetType().GetTypeInfo().Assembly; return assembly.GetManifestResourceStream ("ImageViewerTest.myimage.jpg"); }), } } } } }; }
public App() { Random r = new Random(); DateTime dtFutureOneYear = DateTime.Now.AddDays(r.Next(365, 365*2)); // The root page of your application MainPage = new ContentPage { Content = new StackLayout { VerticalOptions = LayoutOptions.Center, Children = { new Label { Text = "Samples DateTimeExtensions for Xamarin:" , FontSize=20} ,new Label { Text = "Future Date (dd/MM/yyyy hh:mm:ss):" , FontAttributes= FontAttributes.Bold} ,new Label { Text = dtFutureOneYear.ToString("dd/MM/yyyy hh:mm:ss") } ,new Label { Text = "ToExactNaturalText:" + dtFutureOneYear.ToString("dd/MM/yyyy hh:mm:ss") , FontAttributes= FontAttributes.Bold} ,new Label { Text = dtFutureOneYear.ToExactNaturalText(DateTime.Now) } ,new Label { Text = "ToExactNaturalText (es-ES):" , FontAttributes= FontAttributes.Bold} ,new Label { Text = dtFutureOneYear.ToExactNaturalText(DateTime.Now, new DateTimeExtensionsXamarin.NaturalText.NaturalTextCultureInfo("es-ES")) } ,new Label { Text = "ToNaturalText:" , FontAttributes= FontAttributes.Bold} ,new Label { Text = dtFutureOneYear.ToNaturalText(DateTime.Now) } ,new Label { Text = "ToNaturalText (es-ES):" , FontAttributes= FontAttributes.Bold} ,new Label { Text = dtFutureOneYear.ToNaturalText(DateTime.Now, new DateTimeExtensionsXamarin.NaturalText.NaturalTextCultureInfo("es-ES")) } } } }; }
public async void Navigate_ToContentPage_PageHasINavigationAware() { var navigationService = new PageNavigationServiceMock(_container); var rootPage = new Xamarin.Forms.ContentPage(); ((IPageAware)navigationService).Page = rootPage; await navigationService.Navigate("ContentPage"); Assert.True(rootPage.Navigation.ModalStack.Count == 1); var contentPage = rootPage.Navigation.ModalStack[0] as ContentPageMock; Assert.NotNull(contentPage); Assert.True(contentPage.OnNavigatedToCalled); var nextPageNavService = new PageNavigationServiceMock(_container); ((IPageAware)navigationService).Page = contentPage; await navigationService.Navigate("NavigationPage"); Assert.True(contentPage.OnNavigatedFromCalled); Assert.True(contentPage.Navigation.ModalStack.Count == 1); }
public void changeVisiblePage(ContentPage page) { NavigationPage navPage = new NavigationPage(page); navPage.BarBackgroundColor = Theme.getBackgroundColor (); navPage.BarTextColor = Theme.getTextColor(); App.Current.MainPage = navPage; }
private async Task ExecuteLoadItemsCommand() { if (IsBusy) return; IsBusy = true; try{ var httpClient = new HttpClient(); var feed = "http://api.espn.com/v1/sports/soccer/fifa.world/teams?apikey=trs58u4j7gw4aat7ck8dsmgc"; var responseString = await httpClient.GetStringAsync(feed); Teams.Clear(); var items = await ParseFeed(responseString); foreach (var item in items.OrderBy(t => t.Name)) { Teams.Add(item); } keepTeams = Teams.ToList(); } catch (Exception) { var page = new ContentPage(); page.DisplayAlert ("Error", "Unable to load teams.", "OK", null); } IsBusy = false; }
public SearchCheeseViewModel (ContentPage page) { _dataService = DependencyService.Get<ICheeseDataService> (); Title = "Search Cheeses"; Cheeses = new ObservableCollection<Cheese> (); Page = page; }
public async Task ExecuteLoadFlagsCommand() { if (IsBusy) return; IsBusy = true; try { var userManager = new UserManager(Settings.AccessToken); var flags = await userManager.GetFlags(); //Use linq to sorty our monkeys by name and then group them by the new name sort property var sorted = from flag in flags orderby flag.AlertLevel group flag by flag.AlertLevel.ToString() into flagGroup select new Grouping<string, Flag>(flagGroup.Key, flagGroup); //create a new collection of groups FlagsGrouped = new ObservableCollection<Grouping<string, Flag>>(sorted); OnPropertyChanged("FlagsGrouped"); } catch (Exception ex) { var page = new ContentPage(); page.DisplayAlert("Error", "Unable to load flags.", "OK"); ; } finally { IsBusy = false; } }
public LoginXaml (ContentPage parent) { InitializeComponent (); viewModel = new LoginViewModel (); this.parent = parent; BindingContext = viewModel; }
public TodosPage(ContentPage page) { InitializeComponent (); itemsList = new ObservableCollection<TodoModel> (); rootPage = page; todosList.ItemsSource = itemsList; }
public FlyoutFlyoutPageHandler(NativeComponentRenderer renderer, XF.ContentPage flyoutPageControl) : base(renderer, flyoutPageControl) { FlyoutPageControl = flyoutPageControl ?? throw new ArgumentNullException(nameof(flyoutPageControl)); // The Flyout page must have its Title set: https://github.com/xamarin/Xamarin.Forms/blob/5.0.0/Xamarin.Forms.Core/FlyoutPage.cs#L74 ContentPageControl.Title = "Title"; }
public static Page GetMainPage () { var contentPage = new ContentPage { Title = "Progress Bar" }; var codeBehind = new Button { Text = "Code Behind Example" }; var xaml = new Button { Text = "XAML Example" }; codeBehind.Clicked += (sender, args) => { contentPage.Navigation.PushAsync(new ProgressBarCodeBehind()); }; xaml.Clicked += (sender, args) => { contentPage.Navigation.PushAsync(new ProgressBarXAML()); }; contentPage.Content = new StackLayout { Spacing = 10, Padding = 10, Children = { codeBehind, xaml} }; return new NavigationPage (contentPage); }
private async Task ExecuteLoadItemsCommand() { if (IsBusy) return; IsBusy = true; try{ var responseString = string.Empty; using(var httpClient = new HttpClient()) { var feed = "http://feeds.hanselman.com/ScottHanselman"; responseString = await httpClient.GetStringAsync(feed); } FeedItems.Clear(); var items = await ParseFeed(responseString); foreach (var item in items) { FeedItems.Add(item); } } catch (Exception ex) { var page = new ContentPage(); var result = page.DisplayAlert ("Error", "Unable to load blog.", "OK"); } IsBusy = false; }
public static Page GetMainPage() { ContentPage contentPage = new ContentPage(); //Padding agrega un margen al contenido //Device.OnPlatform permite modificar este margen dependiendo de la plataforma IOS, Android y Windows Phone //Para saber más sobe Device.OnPlatform revisa contentPage.Padding = new Thickness (5, Device.OnPlatform (20, 5, 5), 5, 5); //Stacklayout permite apilar los controles verticalmente StackLayout stackLayout = new StackLayout { Children = { new Label { Text = "Blue", TextColor = Color.Blue }, new Label { Text = "Silver", TextColor = Color.Silver }, new Label { Text = "Black", TextColor = Color.Black } } }; contentPage.Content = stackLayout; return contentPage; }
public MainPage() { var menuPageContent = new StackLayout { VerticalOptions = LayoutOptions.Center, }; menuPageContent.Children.Add (new Label { Text = "Menu Drawer", TextColor = Color.Black, HorizontalOptions = LayoutOptions.Center }); var menuPage = new ContentPage { Content = menuPageContent, Title = "Menu Drawer" }; Master = menuPage; var detailPageContent = new StackLayout { VerticalOptions = LayoutOptions.Center }; detailPageContent.Children.Add (new Label { Text = "Landing Page", TextColor = Color.Black, HorizontalOptions = LayoutOptions.Center }); var detailPage = new ContentPage { Content = detailPageContent, Title = "Home" }; Detail = new NavigationPage (detailPage); }
Cell GetCategoryCell (string cat) { var cell = new TextCell {Text = cat}; cell.Tapped += (sender, ea) => {; var category = cat; var tableView = new TableView (); var root = new TableRoot (category); var section = new TableSection (); section.Add (exampleInfoList .Where (e => e.Category == category) .OrderBy (e => e.Title) .Select (e => GetGraphCell(e.Title) )); root.Add (section); tableView.Root = root; var contentPage = new ContentPage { Title = category, Content = new StackLayout { Children = {tableView} } }; Navigation.PushAsync (contentPage); }; return cell; }
internal XF.ContentPage BuildPage(Type type) { var page = new XF.ContentPage(); //Fire and forget is not ideal, could consider a Task.Wait but that's probably worse. _ = PopulatePage(page, type); return(page); }
public MasterPageHandler(NativeComponentRenderer renderer, XF.ContentPage masterDetailPageControl) : base(renderer, masterDetailPageControl) { MasterDetailPageControl = masterDetailPageControl ?? throw new ArgumentNullException(nameof(masterDetailPageControl)); // The Master page must have its Title set: // https://github.com/xamarin/Xamarin.Forms/blob/ff63ef551d9b2b5736092eb48aaf954f54d63417/Xamarin.Forms.Core/MasterDetailPage.cs#L72 ContentPageControl.Title = "Title"; }
public void Navigate_ToUnregisteredPage_ByName() { var navigationService = new PageNavigationServiceMock(_container); var rootPage = new Xamarin.Forms.ContentPage(); ((IPageAware)navigationService).Page = rootPage; navigationService.Navigate("UnregisteredPage"); Assert.True(rootPage.Navigation.ModalStack.Count == 0); }
public static void ShowToastMessage(this Xamarin.Forms.ContentPage page, string strMessage, bool bLong = false) { if (bLong) { instance.LongAlert(strMessage); } else { instance.ShortAlert(strMessage); } }
public async void Navigate_ToContentPage_ByName() { var navigationService = new PageNavigationServiceMock(_container, _applicationProvider, _loggerFacade); var rootPage = new Xamarin.Forms.ContentPage(); ((IPageAware)navigationService).Page = rootPage; await navigationService.NavigateAsync("ContentPage"); Assert.True(rootPage.Navigation.ModalStack.Count == 1); Assert.IsType(typeof(ContentPageMock), rootPage.Navigation.ModalStack[0]); }
public async void DeepNavigate_From_ContentPage_To_CarouselPage() { var navigationService = new PageNavigationServiceMock(_container, _applicationProvider, _loggerFacade); var rootPage = new Xamarin.Forms.ContentPage(); ((IPageAware)navigationService).Page = rootPage; await navigationService.NavigateAsync("ContentPage/CarouselPage"); Assert.True(rootPage.Navigation.ModalStack.Count == 1); Assert.True(rootPage.Navigation.ModalStack[0].Navigation.ModalStack.Count == 1); }
public void Navigate_ToContentPage_ByName() { var navigationService = new PageNavigationServiceMock(_container); var rootPage = new Xamarin.Forms.ContentPage(); ((IPageAware)navigationService).Page = rootPage; navigationService.Navigate("ContentPage"); Assert.True(rootPage.Navigation.ModalStack.Count == 1); Assert.IsType(typeof(ContentPageMock), rootPage.Navigation.ModalStack[0]); }
public async void Navigate_ToContentPage_ByAbsoluteUri() { var navigationService = new PageNavigationServiceMock(_container, _applicationProvider, _loggerFacade); var rootPage = new Xamarin.Forms.ContentPage(); ((IPageAware)navigationService).Page = rootPage; await navigationService.NavigateAsync(new Uri("http://localhost/ContentPage", UriKind.Absolute)); Assert.True(rootPage.Navigation.ModalStack.Count == 0); Assert.IsType(typeof(ContentPageMock), _applicationProvider.MainPage); }
public async void Navigate_ToContentPage_ByObject() { var navigationService = new PageNavigationServiceMock(_container); var rootPage = new Xamarin.Forms.ContentPage(); ((IPageAware)navigationService).Page = rootPage; await navigationService.Navigate <ContentPageMockViewModel>(); Assert.True(rootPage.Navigation.ModalStack.Count == 1); Assert.IsType(typeof(ContentPageMock), rootPage.Navigation.ModalStack[0]); }
public async void DeepNavigate_From_ContentPage_To_MasterDetailPage() { var navigationService = new PageNavigationServiceMock(_container); var rootPage = new Xamarin.Forms.ContentPage(); ((IPageAware)navigationService).Page = rootPage; await navigationService.Navigate("ContentPage/MasterDetailPage"); Assert.True(rootPage.Navigation.ModalStack.Count == 1); Assert.True(rootPage.Navigation.ModalStack[0].Navigation.ModalStack.Count == 1); }
public void Navigate_ToContentPage_ByAbsoluteUri() { var navigationService = new PageNavigationServiceMock(_container); var rootPage = new Xamarin.Forms.ContentPage(); ((IPageAware)navigationService).Page = rootPage; navigationService.Navigate(new Uri("http://brianlagunas.com/ContentPage", UriKind.Absolute)); Assert.True(rootPage.Navigation.ModalStack.Count == 1); Assert.IsType(typeof(ContentPageMock), rootPage.Navigation.ModalStack[0]); }
public async void Navigate_ToContentPage_ByRelativeUri() { var navigationService = new PageNavigationServiceMock(_container); var rootPage = new Xamarin.Forms.ContentPage(); ((IPageAware)navigationService).Page = rootPage; await navigationService.Navigate(new Uri("ContentPage", UriKind.Relative)); Assert.True(rootPage.Navigation.ModalStack.Count == 1); Assert.IsType(typeof(ContentPageMock), rootPage.Navigation.ModalStack[0]); }
public async void DeepNavigate_From_ContentPage_To_NavigationPageWithDifferentNavigationStack_ToContentPage() { var navigationService = new PageNavigationServiceMock(_container); var rootPage = new Xamarin.Forms.ContentPage(); ((IPageAware)navigationService).Page = rootPage; await navigationService.Navigate("ContentPage/NavigationPageWithStackNoMatch/ContentPage"); var navPage = rootPage.Navigation.ModalStack[0].Navigation.ModalStack[0]; Assert.True(navPage.Navigation.NavigationStack.Count == 1); }
public void Navigate_ToUnregisteredPage_ByName() { Assert.ThrowsAsync <NullReferenceException>(async() => { var navigationService = new PageNavigationServiceMock(_container, _applicationProvider, _loggerFacade); var rootPage = new Xamarin.Forms.ContentPage(); ((IPageAware)navigationService).Page = rootPage; await navigationService.NavigateAsync("UnregisteredPage"); Assert.True(rootPage.Navigation.ModalStack.Count == 0); }); }
public void DeepNavigate_From_ContentPage_To_EmptyNavigationPage_ToContentPage() { var navigationService = new PageNavigationServiceMock(_container); var rootPage = new Xamarin.Forms.ContentPage(); ((IPageAware)navigationService).Page = rootPage; navigationService.Navigate("ContentPage/NavigationPage-Empty/ContentPage"); var navPage = rootPage.Navigation.ModalStack[0].Navigation.ModalStack[0]; Assert.True(navPage.Navigation.NavigationStack.Count == 1); }
public async void DeepNavigate_ToTabbedPage_ToPage() { var navigationService = new PageNavigationServiceMock(_container, _applicationProvider, _loggerFacade); var rootPage = new Xamarin.Forms.ContentPage(); ((IPageAware)navigationService).Page = rootPage; await navigationService.NavigateAsync("TabbedPage/PageMock"); var tabbedPage = rootPage.Navigation.ModalStack[0] as TabbedPageMock; Assert.NotNull(tabbedPage); Assert.NotNull(tabbedPage.CurrentPage); Assert.IsType(typeof(PageMock), tabbedPage.CurrentPage); }
public async void DeepNavigate_ToEmptyMasterDetailPage_ToNavigationPage() { var navigationService = new PageNavigationServiceMock(_container, _applicationProvider, _loggerFacade); var rootPage = new Xamarin.Forms.ContentPage(); ((IPageAware)navigationService).Page = rootPage; await navigationService.NavigateAsync("MasterDetailPage-Empty/NavigationPage"); var masterDetail = rootPage.Navigation.ModalStack[0] as MasterDetailPageEmptyMock; Assert.NotNull(masterDetail); Assert.NotNull(masterDetail.Detail); Assert.IsType(typeof(NavigationPageMock), masterDetail.Detail); }
public void DeepNavigate_ToEmptyMasterDetailPage_ToContentPage() { var navigationService = new PageNavigationServiceMock(_container); var rootPage = new Xamarin.Forms.ContentPage(); ((IPageAware)navigationService).Page = rootPage; navigationService.Navigate("MasterDetailPage-Empty/ContentPage"); var masterDetail = rootPage.Navigation.ModalStack[0] as MasterDetailPageEmptyMock; Assert.NotNull(masterDetail); Assert.NotNull(masterDetail.Detail); Assert.IsType(typeof(ContentPageMock), masterDetail.Detail); }
public void DeepNavigate_ToTabbedPage_ToPage() { var navigationService = new PageNavigationServiceMock(_container); var rootPage = new Xamarin.Forms.ContentPage(); ((IPageAware)navigationService).Page = rootPage; navigationService.Navigate("TabbedPage/PageMock"); var tabbedPage = rootPage.Navigation.ModalStack[0] as TabbedPageMock; Assert.NotNull(tabbedPage); Assert.NotNull(tabbedPage.CurrentPage); Assert.IsType(typeof(PageMock), tabbedPage.CurrentPage); }
public async void DeepNavigate_ToCarouselPage_ToContentPage() { var navigationService = new PageNavigationServiceMock(_container); var rootPage = new Xamarin.Forms.ContentPage(); ((IPageAware)navigationService).Page = rootPage; await navigationService.Navigate("CarouselPage/ContentPage"); var tabbedPage = rootPage.Navigation.ModalStack[0] as CarouselPageMock; Assert.NotNull(tabbedPage); Assert.NotNull(tabbedPage.CurrentPage); Assert.IsType(typeof(ContentPageMock), tabbedPage.CurrentPage); }
public async void DeepNavigate_ToMasterDetailPage_ToDifferentPage() { var navigationService = new PageNavigationServiceMock(_container); var rootPage = new Xamarin.Forms.ContentPage(); ((IPageAware)navigationService).Page = rootPage; await navigationService.Navigate("MasterDetailPage/TabbedPage"); var masterDetail = rootPage.Navigation.ModalStack[0] as MasterDetailPageMock; Assert.NotNull(masterDetail); Assert.NotNull(masterDetail.Detail); Assert.IsType(typeof(TabbedPageMock), masterDetail.Detail); }
private static ElementHandler CreateHandler(XF.Element parent, MobileBlazorBindingsRenderer renderer) { return(parent switch { XF.ContentPage contentPage => new ContentPageHandler(renderer, contentPage), XF.ContentView contentView => new ContentViewHandler(renderer, contentView), XF.Label label => new LabelHandler(renderer, label), XF.FlyoutPage flyoutPage => new FlyoutPageHandler(renderer, flyoutPage), XF.ScrollView scrollView => new ScrollViewHandler(renderer, scrollView), XF.ShellContent shellContent => new ShellContentHandler(renderer, shellContent), XF.Shell shell => new ShellHandler(renderer, shell), XF.ShellItem shellItem => new ShellItemHandler(renderer, shellItem), XF.ShellSection shellSection => new ShellSectionHandler(renderer, shellSection), XF.TabbedPage tabbedPage => new TabbedPageHandler(renderer, tabbedPage), _ => new ElementHandler(renderer, parent), });
public async void DeepNavigate_From_ContentPage_To_NavigationPage_ToContentPage_ByAbsoluteUri() { var navigationService = new PageNavigationServiceMock(_container, _applicationProvider, _loggerFacade); var rootPage = new Xamarin.Forms.ContentPage(); ((IPageAware)navigationService).Page = rootPage; await navigationService.NavigateAsync(new Uri("http://localhost/NavigationPage/ContentPage", UriKind.Absolute)); Assert.Equal(0, rootPage.Navigation.ModalStack.Count); var navPage = _applicationProvider.MainPage; Assert.IsType <NavigationPageMock>(navPage); Assert.True(navPage.Navigation.NavigationStack.Count == 1); }
public async void Navigate_ToNavigatonPage_ViewModelHasINavigationAware() { var navigationService = new PageNavigationServiceMock(_container); var rootPage = new Xamarin.Forms.ContentPage(); ((IPageAware)navigationService).Page = rootPage; await navigationService.Navigate("NavigationPage"); Assert.True(rootPage.Navigation.ModalStack.Count == 1); Assert.IsType(typeof(NavigationPageMock), rootPage.Navigation.ModalStack[0]); var viewModel = rootPage.Navigation.ModalStack[0].BindingContext as NavigationPageMockViewModel; Assert.NotNull(viewModel); Assert.True(viewModel.OnNavigatedToCalled); }
private static XF.ContentPage GetErrorPageForException(Exception exception) { var errorPage = new XF.ContentPage() { Title = $"Unhandled exception({exception.GetType().Name})", BackgroundColor = XF.Color.White, Content = new XF.StackLayout { Padding = 10, Children = { new XF.Label { FontAttributes = XF.FontAttributes.Bold, FontSize = XF.Device.GetNamedSize(XF.NamedSize.Large, typeof(XF.Label)), Text = "Unhandled exception", }, new XF.Label { Text = exception?.Message, }, new XF.ScrollView { Content = new StackLayout() { Children = { new XF.Label { FontSize = XF.Device.GetNamedSize(XF.NamedSize.Small, typeof(XF.Label)), Text = exception?.StackTrace, }, GetInnerExceptioView(exception?.InnerException) } } }, }, }, }; return(errorPage); }