コード例 #1
0
		public RootMDPNavigationContentPage (string hierarchy) 
		{
			AutomationId = hierarchy + "PageId";

			Master = new ContentPage {
				Title = "Testing 123",
				Content = new StackLayout {
					Children = {
						new Label { Text = "Master" },
						new AbsoluteLayout {
							BackgroundColor = Color.Red,
							VerticalOptions = LayoutOptions.FillAndExpand,
							HorizontalOptions = LayoutOptions.FillAndExpand
						},
						new Button { Text = "Button" }
					}
				}
			};

			Detail = new NavigationPage (new ContentPage {
				Title = "Md->Nav->Con",
				Content = new SwapHierachyStackLayout (hierarchy)
			});

		}
コード例 #2
0
ファイル: Issue1549.cs プロジェクト: Costo/Xamarin.Forms
		public void ConverterIsInvoked ()
		{
			var xaml = @"
<ContentPage 							
xmlns=""http://xamarin.com/schemas/2014/forms"" 
							xmlns:x=""http://schemas.microsoft.com/winfx/2009/xaml""
							xmlns:local=""clr-namespace:Xamarin.Forms.Xaml.UnitTests;assembly=Xamarin.Forms.Xaml.UnitTests"">

<ContentPage.Resources>
<ResourceDictionary>
<local:SeverityColorConverter x:Key=""SeverityColorConverter"" />
</ResourceDictionary>
</ContentPage.Resources>
				<Label Text=""{Binding value, StringFormat='{0}'}"" 
					WidthRequest=""50"" 
					TextColor=""Black""
					x:Name=""label""
					BackgroundColor=""{Binding Severity, Converter={StaticResource SeverityColorConverter}}""
					XAlign=""Center"" YAlign=""Center""/>
</ContentPage>";

			var layout = new ContentPage ().LoadFromXaml (xaml);
			layout.BindingContext = new {Value = "Foo", Severity = "Bar"};
			var label = layout.FindByName<Label> ("label");
			Assert.AreEqual (Color.Blue, label.BackgroundColor);
			Assert.AreEqual (1, SeverityColorConverter.count);
		}
コード例 #3
0
ファイル: TestCases.cs プロジェクト: Costo/Xamarin.Forms
		public void TestCase001 ()
		{
			var xaml = @"<?xml version=""1.0"" encoding=""UTF-8"" ?>
			<ContentPage
			xmlns=""http://xamarin.com/schemas/2014/forms""
			xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml""
			xmlns:local=""clr-namespace:Xamarin.Forms.Xaml.UnitTests;assembly=Xamarin.Forms.Xaml.UnitTests""
			Title=""Home"">
				<local:TestCases.InnerView>
					<Label x:Name=""innerView""/>
				</local:TestCases.InnerView>
				<ContentPage.Content>
					<Grid RowSpacing=""9"" ColumnSpacing=""6"" Padding=""6,9"" VerticalOptions=""Fill"" HorizontalOptions=""Fill"" BackgroundColor=""Red"">
						<Grid.Children>
							<Label x:Name=""label0""/>
							<Label x:Name=""label1""/>
							<Label x:Name=""label2""/>
							<Label x:Name=""label3""/>
						</Grid.Children>
					</Grid>
				</ContentPage.Content>
			</ContentPage>";
			var contentPage = new ContentPage ().LoadFromXaml (xaml);
			var label0 = contentPage.FindByName<Label> ("label0");
			var label1 = contentPage.FindByName<Label> ("label1");

			Assert.NotNull (GetInnerView (contentPage));
//			Assert.AreEqual ("innerView", GetInnerView (contentPage).Name);
			Assert.AreEqual (GetInnerView (contentPage), ((Forms.Internals.INameScope)contentPage).FindByName ("innerView"));
			Assert.NotNull (label0);
			Assert.NotNull (label1);
			Assert.AreEqual (4, contentPage.Content.Descendants ().Count ());
		}
コード例 #4
0
ファイル: Add.aspx.cs プロジェクト: daniela12/gooptic
    /// <summary>
    /// Bind data to the fields 
    /// </summary>
    protected void BindData()
    {
        ContentPageAdmin pageAdmin = new ContentPageAdmin();
        ContentPage contentPage = new ContentPage();

        if (ItemId > 0)
        {
            contentPage = pageAdmin.GetPageByID(ItemId);

            //set fields
            txtName.Text = contentPage.Name.Trim();
            txtSEOMetaDescription.Text = contentPage.SEOMetaDescription;
            txtSEOMetaKeywords.Text = contentPage.SEOMetaKeywords;
            txtSEOTitle.Text = contentPage.SEOTitle;
            txtSEOUrl.Text = contentPage.SEOURL;
            txtTitle.Text = contentPage.Title;
            ddlPageTemplateList.SelectedValue = contentPage.MasterPage;

            //get content
            ctrlHtmlText.Html = pageAdmin.GetPageHTMLByName(contentPage.Name);
            if (contentPage.Name.Contains("Home"))
            {
                pnlSEOURL.Visible = false;
            }
        }
        else
        {
           //nothing to do here
        }
    }
コード例 #5
0
ファイル: Bugzilla32230.cs プロジェクト: Costo/Xamarin.Forms
		protected override void Init ()
		{
			_lblCount = new Label { Text = _count.ToString (), AutomationId = "lblCount" };
			_btnOpen = new Button { Text = "Open", AutomationId = "btnOpen", 
				Command = new Command (() => {
					IsPresented = true;
				})
			};
			_btnClose = new Button { Text = "Close", AutomationId = "btnClose", 
				Command = new Command (() => {
					IsPresented = false;
				})
			};

			Master = new ContentPage {
				Title = "Master",
				Content = new StackLayout { Children = { _lblCount, _btnClose } }
			};

			Detail = new NavigationPage (new ContentPage { Content = _btnOpen });
			IsPresentedChanged += (object sender, EventArgs e) => {
				_count++;
				_lblCount.Text = _count.ToString();
			};
		}
コード例 #6
0
		public RootTabbedNavigationContentPage (string hierarchy)
		{
			AutomationId = hierarchy + "PageId";

			var tabOne = new NavigationPage (new ContentPage {
				Title = "Nav title",
				Content = new SwapHierachyStackLayout (hierarchy)
			}) { Title = "Tab 123", };

			var tabTwo = new ContentPage {
				Title = "Testing 345",
				Content = new StackLayout {
					Children = {
						new Label { Text = "Hello" },
						new AbsoluteLayout {
							BackgroundColor = Color.Red,
							VerticalOptions = LayoutOptions.FillAndExpand,
							HorizontalOptions = LayoutOptions.FillAndExpand
						},
						new Button { Text = "Button" },
					}
				}
			};

			Children.Add (tabOne);
			Children.Add (tabTwo);
		}
コード例 #7
0
		public void UseTypeConverters ()
		{
			var xaml = @"
			<ContentPage xmlns=""http://xamarin.com/schemas/2014/forms""
             xmlns:x=""http://schemas.microsoft.com/winfx/2009/xaml""
             Title=""Grid Demo Page"">
			  <ContentPage.Padding>
			    <OnPlatform x:TypeArguments=""Thickness"">
			      <OnPlatform.iOS>
			        0, 20, 0, 0
			      </OnPlatform.iOS>
			      <OnPlatform.Android>
			        0, 0, 10, 0
			      </OnPlatform.Android>
			      <OnPlatform.WinPhone>
			        0, 20, 0, 20
			      </OnPlatform.WinPhone>
			    </OnPlatform>
			  </ContentPage.Padding>  
			</ContentPage>";

			ContentPage layout;

			Device.OS = TargetPlatform.iOS;
			layout = new ContentPage ().LoadFromXaml (xaml);
			Assert.AreEqual (new Thickness (0, 20, 0, 0), layout.Padding);

			Device.OS = TargetPlatform.Android;
			layout = new ContentPage ().LoadFromXaml (xaml);
			Assert.AreEqual (new Thickness (0, 0, 10, 0), layout.Padding);

			Device.OS = TargetPlatform.WinPhone;
			layout = new ContentPage ().LoadFromXaml (xaml);
			Assert.AreEqual (new Thickness (0, 20, 0, 20), layout.Padding);
		}
コード例 #8
0
    /// <summary>
    /// Run the code example.
    /// </summary>
    /// <param name="user">The DFP user object running the code example.</param>
    public override void Run(DfpUser user) {
      // Get the ContentService.
      ContentService contentService =
          (ContentService) user.GetService(DfpService.v201508.ContentService);

      // Create a statement to get all content.
      StatementBuilder statementBuilder = new StatementBuilder()
          .OrderBy("id ASC")
          .Limit(StatementBuilder.SUGGESTED_PAGE_LIMIT);

      // Set default for page.
      ContentPage page = new ContentPage();

      try {
        do {
          // Get content by statement.
          page = contentService.getContentByStatement(statementBuilder.ToStatement());

          if (page.results != null) {
            int i = page.startIndex;
            foreach (Content content in page.results) {
              Console.WriteLine("{0}) Content with ID \"{1}\", name \"{2}\", and status \"{3}\" " +
                  "was found.", i, content.id, content.name, content.status);
              i++;
            }
          }
          statementBuilder.IncreaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
        } while (statementBuilder.GetOffset() < page.totalResultSetSize);

        Console.WriteLine("Number of results found: " + page.totalResultSetSize);
      } catch (Exception e) {
        Console.WriteLine("Failed to get all content. Exception says \"{0}\"", e.Message);
      }
    }
コード例 #9
0
		public async Task TestNavigationImplPop ()
		{
			NavigationPage nav = new NavigationPage ();
			
			Label child = new Label ();
			Page childRoot = new ContentPage {Content = child};

			Label child2 = new Label ();
			Page childRoot2 = new ContentPage {Content = child2};
			
			await nav.Navigation.PushAsync (childRoot);
			await nav.Navigation.PushAsync (childRoot2);

			bool fired = false;
			nav.Popped += (sender, e) => fired = true;
			var popped = await nav.Navigation.PopAsync ();

			Assert.True (fired);
			Assert.AreSame (childRoot, nav.CurrentPage);
			Assert.AreEqual (childRoot2, popped);

			await nav.PopAsync ();
			var last = await nav.Navigation.PopAsync ();

			Assert.IsNull (last);
		}
コード例 #10
0
		public RootMDPNavigationTabbedContentPage (string hierarchy)
		{
			AutomationId = hierarchy + "PageId";


			var tabbedPage = new TabbedPage ();

			var firstTab = new ContentPage {
				//BackgroundColor = Color.Yellow,
				Title = "Testing 123",
				Content = new SwapHierachyStackLayout (hierarchy)
			};

			tabbedPage.Children.Add (firstTab);

			NavigationPage.SetHasNavigationBar (firstTab, false);

			Detail = new NavigationPage (tabbedPage);
			Master = new NavigationPage (new ContentPage {
				Title = "Testing 345",
				Content = new StackLayout {
					Children = {
						new Label { Text = "Hello" },
						new AbsoluteLayout {
							BackgroundColor = Color.Red,
							VerticalOptions = LayoutOptions.FillAndExpand,
							HorizontalOptions = LayoutOptions.FillAndExpand
						},
						new Button { Text = "Button" }
					}
				}
			}) { 
				Title = "Testing 345"
			};
		}
コード例 #11
0
ファイル: pages_edit.aspx.cs プロジェクト: daniela12/gooptic
    /// <summary>
    /// Bind data to the fields 
    /// </summary>
    protected void BindData()
    {
        ContentPageAdmin pageAdmin = new ContentPageAdmin();
        ContentPage contentPage = new ContentPage();

        if (ItemId > 0)
        {
            contentPage = pageAdmin.GetPageByID(ItemId);

            //set fields
            lblTitle.Text += contentPage.Title;
            txtTitle.Text = contentPage.Title;
            txtSEOMetaDescription.Text = contentPage.SEOMetaDescription;
            txtSEOMetaKeywords.Text = contentPage.SEOMetaKeywords;
            txtSEOTitle.Text = contentPage.SEOTitle;
            txtSEOUrl.Text = contentPage.SEOURL;

            //get content
            ctrlHtmlText.Html = pageAdmin.GetPageHTMLByName(contentPage.Name);
        }
        else
        {
            //nothing to do here
        }
    }
コード例 #12
0
ファイル: SimpleApp.cs プロジェクト: Costo/Xamarin.Forms
		public SimpleApp()
		{
			var label = new Label { VerticalOptions = LayoutOptions.CenterAndExpand };

			if (Current.Properties.ContainsKey("LabelText"))
			{
				label.Text = (string)Current.Properties["LabelText"] + " Restored!";
				Debug.WriteLine("Initialized");
			}
			else
			{
				Current.Properties["LabelText"] = "Wowza";
				label.Text = (string)Current.Properties["LabelText"] + " Set!";
				Debug.WriteLine("Saved");
			}

			MainPage = new ContentPage
			{
				Content = new StackLayout
				{
					Children =
					{
						label
					}
				}
			};

			SerializeProperties();
		}
コード例 #13
0
ファイル: Issue1545.cs プロジェクト: Costo/Xamarin.Forms
		public void BindingCanNotBeReused()
		{
			string xaml = @"<ContentPage xmlns=""http://xamarin.com/schemas/2014/forms""
						 xmlns:x=""http://schemas.microsoft.com/winfx/2009/xaml""
						 x:Class=""Xamarin.Forms.Controls.Issue1545"">
						<ListView x:Name=""List"" ItemsSource=""{Binding}"">
							<ListView.ItemTemplate>
								<DataTemplate>
									<TextCell Text=""{Binding}"" />
								</DataTemplate>
							</ListView.ItemTemplate>
						</ListView>
				</ContentPage>";

			ContentPage page = new ContentPage().LoadFromXaml (xaml);

			var items = new[] { "Fu", "Bar" };
			page.BindingContext = items;

			ListView lv = page.FindByName<ListView> ("List");
			
			TextCell cell = (TextCell)lv.TemplatedItems.GetOrCreateContent (0, items[0]);
			Assert.That (cell.Text, Is.EqualTo ("Fu"));
			
			cell = (TextCell)lv.TemplatedItems.GetOrCreateContent (1, items[1]);
			Assert.That (cell.Text, Is.EqualTo ("Bar"));
		}
コード例 #14
0
        public ActionResult Index(string content, string subject)
        {
            if (!Application.IsAuthenticated) {
                ViewBag.Header = "Please Log In";
                ViewBag.Message = "Your authorization is not valid for this type of operation";
                return View("Message", "_LayoutGuest");
            }

            try
            {
                ContentPage page = new ContentPage();
                page.Name = subject;
                page.PageContent = content;
                page.DateModified = DateTime.Now;
                page.AdminID = Application.AdminID;
                page.CmsTypeID = 2;
                Application.Db.AddToContentPages(page);
                Application.Db.SaveChanges();
                return RedirectToAction("index");
            }
            catch
            {
                return View();
            }
        }
コード例 #15
0
ファイル: Bugzilla27698.cs プロジェクト: Costo/Xamarin.Forms
		protected override void Init ()
		{

			var showAlertBtn = new Button { Text = "DisplayAlert" };
			var showActionSheetBtn = new Button { Text = "DisplayActionSheet" };

			var master = new ContentPage
			{
				Title = "Master",
				Content = new StackLayout
				{
					VerticalOptions = LayoutOptions.Center,
					Children = {
						showAlertBtn,
						showActionSheetBtn
					}
				}
			};

			Master = master;

			MasterBehavior = MasterBehavior.Popover;

			Detail = new ContentPage {
				Content = new Label { Text = "Details", HorizontalOptions =
					LayoutOptions.Center, VerticalOptions = LayoutOptions.Center
				}
			};

			showAlertBtn.Clicked += (s, e) => DisplayAlert("Title","Message", "Cancel");
			showActionSheetBtn.Clicked += (s, e) => DisplayActionSheet ("Title", "Cancel", null, "Button1", "Button2", "Button3");
			
		}
コード例 #16
0
ファイル: Issue2961.cs プロジェクト: cosullivan/Xamarin.Forms
		void OnMenuSelected (SliderMenuItem menu)
		{
			Debug.WriteLine (IsPresented);

			IsPresented = false;	

			if (menu == null || menu == _selectedMenuItem) {
				return;
			}
			_displayPage = null;

			if (menu.TargetType.Equals (typeof(SignOutPage))) {
				HandleSignOut ();
				return;
			}
			_displayPage = (ContentPage)Activator.CreateInstance (menu.TargetType);
			Detail = new NavigationPage (_displayPage);
		
			if (_selectedMenuItem != null) {
				_selectedMenuItem.IsSelected = false;
			}

			_selectedMenuItem = menu;
			_selectedMenuItem.IsSelected = true;
		}
コード例 #17
0
        public ActionResult Edit(int id = 0, string message = "")
        {
            // Load the page from the database
            ContentPage page = new ContentPage();
            if (id > 0) {
                page = ContentManagement.GetPage(id);
            }
            ViewBag.page = page;

            // Try override 'page' with our page from TempData, in case there was a f*****g error while saving. F**k that error!!
            ContentPage errPage = (ContentPage)TempData["page"];
            if (errPage != null) {
                ViewBag.page = errPage;
            }
            ViewBag.message = TempData["error"];

            // Build out the listing of parent pages i.e. pages who list this page in there menu
            ViewBag.parent_page = page.getParent();

            // Build out the listing of subpages i.e. pages who list this page as their parent page
            ViewBag.sub_pages = page.getSubpages();

            // We need to pass in the fixed_titles so we know when we can't allow the user to edit the title
            string[] fixed_pages = ContentManagement.fixed_pages;
            ViewBag.fixed_pages = fixed_pages;

            return View();
        }
コード例 #18
0
        public EditContentViewModel(int id)
        {
            using (var context = new DataContext())
            {
                ThePage = context.ContentPages.Where(x => x.ContentPageId == id).Take(1).FirstOrDefault();

                // If we are editing a draft, we actually need to be editing the parent page, but keep the drafts contents (html, css, meta, etc).
                // To accomplish this, we can simply change the id of the page we're editing in memory, to the parent page.
                BasePageId = ThePage.IsRevision ? Convert.ToInt32(ThePage.ParentContentPageId) : ThePage.ContentPageId;

                var userName = Membership.GetUser().UserName;
                UseWordWrap = context.Users.FirstOrDefault(x => x.Username == userName).ContentAdminWordWrap;

                SiteUrl = HTTPUtils.GetFullyQualifiedApplicationPath();

                // Take care of any legacy pages that don't have a publish date associated
                if (ThePage.PublishDate == null)
                {
                    ThePage.PublishDate = DateTime.Now;
                    context.SaveChanges();
                }

                // Take care of any legacy pages where Unparsed html was not saved
                if (String.IsNullOrEmpty(ThePage.HTMLUnparsed) && !String.IsNullOrEmpty(ThePage.HTMLContent))
                {
                    ThePage.HTMLUnparsed = ThePage.HTMLContent;
                }

                // Set a permalink if one hasn't been created / legacy support for DisplayName
                if (String.IsNullOrEmpty(ThePage.Permalink))
                {
                    ThePage.Permalink = ContentUtils.GetFormattedUrl(ThePage.DisplayName);
                    context.SaveChanges();
                }

                // Set Page Title if one hasn't been created / legacy support for DisplayName
                if (String.IsNullOrEmpty(ThePage.Title))
                {
                    ThePage.Title = ThePage.DisplayName;
                    context.SaveChanges();
                }

                // Check to see if there is a newer version available
                var newerVersion = context.ContentPages.Where(x => (x.ParentContentPageId == BasePageId || x.ContentPageId == BasePageId) && x.PublishDate > ThePage.PublishDate && x.ContentPageId != ThePage.ContentPageId).OrderByDescending(x => x.PublishDate).FirstOrDefault();

                if (newerVersion != null)
                {
                    IsNewerVersion = true;
                    NewerVersionId = newerVersion.ContentPageId;
                }

                Templates = new ContentTemplates().Templates;

                Revisions = context.ContentPages.Where(x => x.ParentContentPageId == BasePageId || x.ContentPageId == BasePageId).OrderByDescending(x => x.PublishDate).ToList();

                // Get list of schemas for drop down
                Schemas = context.Schemas.ToList();
            }
        }
コード例 #19
0
		public void TestMasterSetter ()
		{
			MasterDetailPage page = new MasterDetailPage ();
			var child = new ContentPage {Content = new Label (), Title = "Foo"};
			page.Master = child;

			Assert.AreEqual (child, page.Master);
		}
コード例 #20
0
		public void TestMasterSetNull ()
		{
			MasterDetailPage page = new MasterDetailPage ();
			var child = new ContentPage {Content = new Label (), Title = "Foo"};
			page.Master = child;

			Assert.Throws<ArgumentNullException> (() => { page.Master = null; });
		}
コード例 #21
0
        public ContentPage GetAboutPage()
        {
            var page = new ContentPage();
            page.Title = "About us";
            page.Description = "This page introduces us";

            return page;
        }
コード例 #22
0
ファイル: PageTests.cs プロジェクト: Costo/Xamarin.Forms
		public void TestConstructor ()
		{
			var child = new Label ();
			Page root = new ContentPage {Content = child};

			Assert.AreEqual (root.LogicalChildren.Count, 1);
			Assert.AreSame (root.LogicalChildren.First (), child);
		}
コード例 #23
0
		public override void RenderTemplate(HtmlHelper html, ContentItem item)
		{
			ContentPage page = new ContentPage();
			page.CurrentPage = html.CurrentPage();

			N2.Web.UI.ItemUtility.AddUserControl(page, item);

			page.RenderControl(new HtmlTextWriter(html.ViewContext.Writer));
		}
コード例 #24
0
		public override void RenderTemplate(HtmlHelper html, ContentItem item)
		{
			ContentPage page = new ContentPage();
			page.CurrentPage = html.CurrentPage();

			Engine.ResolveAdapter<PartsAdapter>(page.CurrentPage).AddChildPart(item, page);

			page.RenderControl(new HtmlTextWriter(html.ViewContext.Writer));
		}
コード例 #25
0
        public override void RenderPart(HtmlHelper html, ContentItem part, System.IO.TextWriter writer = null)
        {
            ContentPage page = new ContentPage();
            page.CurrentPage = html.CurrentPage();

            Engine.ResolveAdapter<PartsAdapter>(page.CurrentPage).AddChildPart(part, page);

            page.RenderControl(new HtmlTextWriter(html.ViewContext.Writer));
        }
コード例 #26
0
		public void SimpleTrackEmpty ()
		{
			var tracker = new ToolbarTracker ();

			var page = new ContentPage ();
			tracker.Target = page;

			Assert.False (tracker.ToolbarItems.Any ());
		}
コード例 #27
0
ファイル: Bugzilla37601.cs プロジェクト: Costo/Xamarin.Forms
        public TabbedMain ()
        {
            var page1 = new ContentPage { Title = "Page1" };
            page1.Content = new StackLayout {
                Children = { new Label { Text = "If you can see this, we haven't crashed. Yay!" } }
            };

           Children.Add (page1);
           Children.Add (new ContentPage { Title = "Page2" });
        }
コード例 #28
0
		public void PushFirstItem ()
		{
			var navModel = new NavigationModel ();

			var page1 = new ContentPage ();
			navModel.Push (page1, null);

			Assert.AreEqual (page1, navModel.CurrentPage);
			Assert.AreEqual (page1, navModel.Roots.First ());
		}
コード例 #29
0
ファイル: AppLifeCycle.cs プロジェクト: Costo/Xamarin.Forms
		public AppLifeCycle()
		{
			MainPage = new ContentPage
			{
				Content = new Label
				{
					Text = "Testing Lifecycle events"
				}
			};
		}
コード例 #30
0
ファイル: pages_edit.aspx.cs プロジェクト: daniela12/gooptic
    /// <summary>
    /// Submit button click event
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        ContentPageAdmin pageAdmin = new ContentPageAdmin();
        ContentPage contentPage = new ContentPage();
        string mappedSEOUrl = "";

        bool allowDelete = true;

        // If edit mode then retrieve data first
        if (ItemId > 0)
        {
            contentPage = pageAdmin.GetPageByID(ItemId);
            allowDelete = contentPage.AllowDelete; //override this setting
            if (contentPage.SEOURL != null)
                mappedSEOUrl = contentPage.SEOURL;
        }

        // set values
        contentPage.ActiveInd = true;
        contentPage.Title = txtTitle.Text;
        contentPage.PortalID = ZNodeConfigManager.SiteConfig.PortalID;
        contentPage.SEOMetaDescription = txtSEOMetaDescription.Text;
        contentPage.SEOMetaKeywords = txtSEOMetaKeywords.Text;
        contentPage.SEOTitle = txtSEOTitle.Text;
        contentPage.SEOURL = null;
        if (txtSEOUrl.Text.Trim().Length > 0)
            contentPage.SEOURL = txtSEOUrl.Text.Trim().Replace(" ", "-");

        bool retval = false;

        if (ItemId > 0)
        {
            // update code here
            retval = pageAdmin.UpdatePage(contentPage, ctrlHtmlText.Html, HttpContext.Current.User.Identity.Name, mappedSEOUrl, chkAddURLRedirect.Checked);
        }

        if (retval)
        {
            // redirect to main page
            Response.Redirect(ManageLink);
        }
        else
        {
            if (contentPage.SEOURL != null)
            {
                // display error message
                lblMsg.Text = "Failed to update page. Please check with SEO Url settings and try again.";
            }
            else
            {
                // display error message
                lblMsg.Text = "Failed to update page. Please try again.";
            }
        }
    }
コード例 #31
0
        protected override void Init()
        {
            var showAlertBtn = new Button {
                Text = "DisplayAlert"
            };
            var showActionSheetBtn = new Button {
                Text = "DisplayActionSheet"
            };

            var master = new ContentPage
            {
                Title   = "Master",
                Content = new StackLayout
                {
                    VerticalOptions = LayoutOptions.Center,
                    Children        =
                    {
                        showAlertBtn,
                        showActionSheetBtn
                    }
                }
            };

            Master = master;

            MasterBehavior = MasterBehavior.Popover;

            Detail = new ContentPage {
                Content = new Label {
                    Text = "Details", HorizontalOptions =
                        LayoutOptions.Center, VerticalOptions = LayoutOptions.Center
                }
            };

            showAlertBtn.Clicked       += (s, e) => DisplayAlert("Title", "Message", "Cancel");
            showActionSheetBtn.Clicked += (s, e) => DisplayActionSheet("Title", "Cancel", null, "Button1", "Button2", "Button3");
        }
コード例 #32
0
        public Ooui.Element CreateElement()
        {
            var panel = new StackLayout();

            var titleLabel = new Xamarin.Forms.Label
            {
                Text           = "Slider",
                FontSize       = 24,
                FontAttributes = FontAttributes.Bold
            };

            panel.Children.Add(titleLabel);

            Slider slider = new Slider
            {
                Minimum = 0,
                Maximum = 100
            };

            panel.Children.Add(slider);

            slider.ValueChanged += OnSliderValueChanged;

            _label = new Xamarin.Forms.Label
            {
                Text = "Slider value is 0",
                HorizontalOptions = LayoutOptions.Center
            };
            panel.Children.Add(_label);

            var page = new ContentPage
            {
                Content = panel
            };

            return(page.GetOouiElement());
        }
コード例 #33
0
        async void OnGenerateButtonClicked(object sender, EventArgs args)
        {
            ContentPage contentPage = new ContentPage
            {
                Title   = titleEntry.Text,
                Padding = new Thickness(10, 0)
            };
            StackLayout stackLayout = new StackLayout();

            contentPage.Content = stackLayout;

            foreach (string item in viewCollection)
            {
                string viewString = item.Substring(0, item.IndexOf(' '));
                Type   viewType   = xamarinForms.GetType("Xamarin.Forms." + viewString);
                View   view       = (View)Activator.CreateInstance(viewType);
                view.VerticalOptions = LayoutOptions.CenterAndExpand;

                switch (viewString)
                {
                case "BoxView":
                    ((BoxView)view).Color = Color.Accent;
                    goto case "Stepper";

                case "Button":
                    ((Button)view).Text = item;
                    goto case "Stepper";

                case "Stepper":
                case "Switch":
                    view.HorizontalOptions = LayoutOptions.Center;
                    break;
                }
                stackLayout.Children.Add(view);
            }
            await Navigation.PushAsync(contentPage);
        }
コード例 #34
0
        public App()
        {
            #region Create Main UI
            // To define the Main UI of the Xamarin.Form app
            // Instantiate a Page class
            // Populate it with Layouts and Controls
            // Assign to the App.MainPage property
            #endregion

            #region Markup as UI definition
            // Modern UI frameworks default to markup languages for UI definition
            // HTML, AXML, .XIB, .Storyboard, XAML
            #endregion

            // The root page of your application
            MainPage =
                new ContentPage
            {
                Content = new StackLayout
                {
                    VerticalOptions = LayoutOptions.Start,
                    Children        =
                    {
                        new Label {
                            HorizontalTextAlignment = TextAlignment.Center,
                            Text     = "Tailor-made Tour Stops",
                            FontSize = 24
                        },
                        new Label {
                            HorizontalTextAlignment = TextAlignment.Center,
                            Text     = TourStops.Models.TourSource.First().Name,
                            FontSize = 20,
                        }
                    }
                }
            };
        }
コード例 #35
0
        public static Form ShowXamarinControl(this ContentPage ctl, int Width, int Height)
        {
            var f = new Xamarin.Forms.Platform.WinForms.PlatformRenderer();

            Xamarin.Forms.Platform.WinForms.Forms.Init(f);

            f.Width  = Width;
            f.Height = Height;
            var app = new Xamarin.Forms.Application()
            {
                MainPage = ctl
            };

            f.LoadApplication(app);
            ThemeManager.ApplyThemeTo(f);
            if (ctl is IClose)
            {
                ((IClose)ctl).CloseAction = () => f.Close();
            }

            f.ShowDialog();

            return(f);
        }
コード例 #36
0
        public void TestBindingModeAndConverter()
        {
            var xaml = @"
				<ContentPage 
				xmlns=""http://xamarin.com/schemas/2014/forms""
				xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml""
				xmlns:local=""clr-namespace:Xamarin.Forms.Xaml.UnitTests;assembly=Xamarin.Forms.Xaml.UnitTests"">
					<ContentPage.Resources>
						<ResourceDictionary>
							<local:ReverseConverter x:Key=""reverseConverter""/>
						</ResourceDictionary>
					</ContentPage.Resources>
					<ContentPage.Content>
						<StackLayout Orientation=""Vertical"">
							<StackLayout.Children>
								<Label x:Name=""label0"" Text=""{Binding Text, Converter={StaticResource reverseConverter}}""/>
								<Label x:Name=""label1"" Text=""{Binding Text, Mode=TwoWay}""/>
							</StackLayout.Children>
						</StackLayout>
					</ContentPage.Content>
				</ContentPage>"                ;

            var contentPage = new ContentPage();

            contentPage.LoadFromXaml(xaml);
            contentPage.BindingContext = new ViewModel {
                Text = "foobar"
            };
            var label0 = contentPage.FindByName <Label> ("label0");
            var label1 = contentPage.FindByName <Label> ("label1");

            Assert.AreEqual("raboof", label0.Text);

            label1.Text = "baz";
            Assert.AreEqual("baz", ((ViewModel)(contentPage.BindingContext)).Text);
        }
コード例 #37
0
        public TabbedHomePage()
        {
            ContentPage mPage = new ContentPage()
            {
                Title = "ALL"
            };
            ContentView content = new MovieListView(0);

            content.ClassId = "0";
            mPage.Content   = content;
            mPage.ClassId   = "0";
            mPage.Title     = "All";

            Children.Add(mPage);

            var GList = App.MovieGenre.ToList();

            foreach (var item in GList)
            {
                // Task.Run(()=>{
                mPage = new ContentPage()
                {
                    Title = item.Value
                };
                content         = new MovieListView(item.Key);
                content.ClassId = item.Key.ToString();
                mPage.Content   = content;
                mPage.ClassId   = item.Key.ToString();
                mPage.Title     = item.Value.ToString();

                Children.Add(mPage);
                //});
            }

            InitializeComponent();
        }
コード例 #38
0
    public async Task<ActionResult> ContentPageUpdate(int? id)
    {
      var userId = User.Identity.GetUserId();
      var user = await UserManager.FindByIdAsync(userId);
      ViewBag.Roles = RoleManager.Roles.OrderBy(ob => ob.Name).ToList();

      var model = new ContentPage();

      var modelPageRoles = await _contentPageRoleService.Query().SelectAsync();
      model.ContentPageRoles = modelPageRoles.ToList();

      if (!id.HasValue || id == 0)
      {
        model.Author = user.FullName;
      }
      else
      {
        model = await _contentPageService.FindAsync(id);
        var contentPageRoles = await _contentPageRoleService.Query(x => x.ContentPageID == id.Value).SelectAsync();
        model.ContentPageRoles = contentPageRoles.ToList();
      }

      return View(model);
    }
コード例 #39
0
        public async Task MultiplePopsRemoveMiddlePagesBeforeFinalPop()
        {
            TestShell testShell = new TestShell(
                CreateShellSection <NavigationMonitoringTab>(shellContentRoute: "rootpage")
                );

            var pageLeftOnStack = new ContentPage();
            var tab             = (NavigationMonitoringTab)testShell.CurrentItem.CurrentItem;
            await testShell.Navigation.PushAsync(pageLeftOnStack);

            await testShell.Navigation.PushAsync(new ContentPage());

            await testShell.Navigation.PushAsync(new ContentPage());

            tab.NavigationsFired.Clear();
            await testShell.GoToAsync("../..");

            Assert.That(testShell.CurrentState.Location.ToString(),
                        Is.EqualTo($"//rootpage/{Routing.GetRoute(pageLeftOnStack)}"));

            Assert.AreEqual("OnRemovePage", tab.NavigationsFired[0]);
            Assert.AreEqual("OnPopAsync", tab.NavigationsFired[1]);
            Assert.AreEqual(2, tab.NavigationsFired.Count);
        }
コード例 #40
0
ファイル: Issue6484.cs プロジェクト: hevey/maui
        async void OnPageAppearing(object sender, EventArgs e)
        {
            page.Appearing -= OnPageAppearing;

            var removeMe = new ContentPage();
            await Navigation.PushAsync(removeMe);

            await Navigation.PushAsync(new ContentPage());

            await Task.Delay(1);

            Navigation.RemovePage(removeMe);
            await Navigation.PopAsync();


            await Task.Delay(1);

            layout.Children.Add(
                new Label()
            {
                Text         = "If app hasn't crashed test has succeeded",
                AutomationId = "Success"
            });
        }
コード例 #41
0
        public async Task FlyoutViewVisualPropagation()
        {
            Shell       shell = new Shell();
            ContentPage page  = new ContentPage();

            shell.Items.Add(CreateShellItem(page));


            // setup title view
            StackLayout flyoutView = new StackLayout()
            {
                BackgroundColor = Colors.White
            };
            Button button = new Button();

            flyoutView.Children.Add(button);
            shell.SetValue(Shell.FlyoutHeaderProperty, flyoutView);

            IVisualController visualController = button as IVisualController;

            Assert.AreEqual(VisualMarker.Default, visualController.EffectiveVisual);
            shell.Visual = VisualMarker.Material;
            Assert.AreEqual(VisualMarker.Material, visualController.EffectiveVisual);
        }
コード例 #42
0
        void LoadDetailPage(string message)
        {
            var colorConverter = new ColorTypeConverter();


            var page = new ContentPage()
            {
                Content = new Label()
                {
                    Text           = message,
                    FontAttributes = FontAttributes.Bold,
                },
                BackgroundColor = (Color)colorConverter.ConvertFromInvariantString(message),
            };

            page.On <Xamarin.Forms.PlatformConfiguration.iOS>().SetUseSafeArea(true);

            masterDetailPage.Detail = new Xamarin.Forms.NavigationPage(page);

            if (masterDetailPage.CanChangeIsPresented)
            {
                masterDetailPage.IsPresented = false;
            }
        }
コード例 #43
0
        /// <summary>
        ///     <para>Runs the Dropbox OAuth authorization process if not yet authenticated.</para>
        ///     <para>Upon completion <seealso cref="OnAuthenticated"/> is called</para>
        /// </summary>
        /// <returns>An asynchronous task.</returns>
        public async Task Authorize()
        {
            if (string.IsNullOrWhiteSpace(this.AccessToken) == false)
            {
                // Already authorized
                this.OnAuthenticated?.Invoke();
                return;
            }

            if (this.GetAccessTokenFromSettings())
            {
                // Found token and set AccessToken 
                return;
            }

            // Run Dropbox authentication
            this.oauth2State = Guid.NewGuid().ToString("N");
            var authorizeUri = DropboxOAuth2Helper.GetAuthorizeUri(OAuthResponseType.Token, "zgomjzxhw2j7lvq", new Uri("http://localhost/"), this.oauth2State);
            Console.WriteLine("URI ======> {0}", authorizeUri);
            var webView = new WebView { Source = new UrlWebViewSource { Url = authorizeUri.AbsoluteUri } };
            webView.Navigating += this.WebViewOnNavigating;
            var contentPage = new ContentPage { Content = webView };
            await Application.Current.MainPage.Navigation.PushModalAsync(contentPage);
        }
コード例 #44
0
        private async void onImageClicked(ImageSource source)
        {
            var         modalPage  = new ContentPage();
            ScrollView  view       = new ScrollView();
            StackLayout layout     = new StackLayout();
            CachedImage image      = new CachedImage();
            PinchZoom   pinchImage = new PinchZoom();

            image.Source = source;
            image.Margin = new Thickness(0, 130, 0, 130);
            image.DownsampleToViewSize = false;
            image.VerticalOptions      = LayoutOptions.Center;
            image.HorizontalOptions    = LayoutOptions.Center;
            view.VerticalOptions       = LayoutOptions.CenterAndExpand;
            layout.VerticalOptions     = LayoutOptions.CenterAndExpand;

            pinchImage.Content = image;
            //pinchImage.IsClippedToBounds = true;
            layout.Children.Add(pinchImage);
            view.Content      = layout;
            modalPage.Content = view;

            await navigation.PushModalAsync(modalPage);
        }
コード例 #45
0
ファイル: AppBarSample.cs プロジェクト: yunmiha/TizenFX
        private void CreateSecondPage()
        {
            secondActionButton = new Button()
            {
                Text = "Page 1",
            };
            secondActionButton.Clicked += (object sender, ClickedEventArgs e) =>
            {
                NUIApplication.GetDefaultWindow().GetDefaultNavigator().Pop();
            };

            secondAppBar = new AppBar()
            {
                Title   = "Second Page",
                Actions = new View[] { secondActionButton },
            };

            secondButton = new Button()
            {
                Text = "Click to prev",
                WidthSpecification  = LayoutParamPolicies.MatchParent,
                HeightSpecification = LayoutParamPolicies.MatchParent,
            };
            secondButton.Clicked += (object sender, ClickedEventArgs e) =>
            {
                NUIApplication.GetDefaultWindow().GetDefaultNavigator().Pop();
            };

            secondPage = new ContentPage()
            {
                AppBar  = secondAppBar,
                Content = secondButton,
            };

            NUIApplication.GetDefaultWindow().GetDefaultNavigator().Push(secondPage);
        }
コード例 #46
0
ファイル: App.xaml.cs プロジェクト: BDavidd/XamarinTraining
        public App()
        {
            //InitializeComponent();

            //MainPage = new FirstApp.MainPage();

            var layout = new StackLayout
            {
                VerticalOptions = LayoutOptions.Center,
                Children        =
                {
                    new Label
                    {
                        HorizontalTextAlignment = TextAlignment.Center,
                        Text = "Welcome to Xamarin Forms!"
                    }
                }
            };

            MainPage = new ContentPage
            {
                Content = layout
            };

            Button button = new Button
            {
                Text = "Test"
            };

            button.Clicked += async(s, e) =>
            {
                await MainPage.DisplayAlert("Alert", "You clicked me", "OK");
            };

            layout.Children.Add(button);
        }
コード例 #47
0
        public void TestLayoutWithContainerArea()
        {
            View child;
            var  page = new ContentPage {
                Content = child = new View {
                    WidthRequest      = 100,
                    HeightRequest     = 200,
                    IsPlatformEnabled = true
                },
                IsPlatformEnabled = true,
                Platform          = new UnitPlatform()
            };

            page.Layout(new Rectangle(0, 0, 800, 800));

            Assert.AreEqual(new Rectangle(0, 0, 800, 800), child.Bounds);
            ((IPageController)page).ContainerArea = new Rectangle(10, 10, 30, 30);

            Assert.AreEqual(new Rectangle(10, 10, 30, 30), child.Bounds);

            page.Layout(new Rectangle(0, 0, 50, 50));

            Assert.AreEqual(new Rectangle(10, 10, 30, 30), child.Bounds);
        }
コード例 #48
0
ファイル: TabbedPageWindows.cs プロジェクト: hevey/maui
        static Page CreateSecondPage()
        {
            var cp = new ContentPage {
                Title = "Second Content Page"
            };

            var content = new StackLayout
            {
                VerticalOptions   = LayoutOptions.Fill,
                HorizontalOptions = LayoutOptions.Fill
            };

            content.Children.Add(new Label
            {
                Text                    = "Page 2",
                FontAttributes          = FontAttributes.Bold,
                HorizontalTextAlignment = TextAlignment.Center,
                VerticalTextAlignment   = TextAlignment.Center
            });

            cp.Content = content;

            return(cp);
        }
コード例 #49
0
        public async Task ExecuteLoadUsersCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                var adminManager = new AdminManager(Settings.AccessToken);


                var users = await adminManager.FlagUserList(Flag.Id);

                //Use linq to users by name and then group them by the new name sort property
                var sorted = from user in users
                             orderby user.NickName
                             group user by(user.NickName.Length == 0? "?" : user.NickName[0].ToString()) into userGroup
                             select new Grouping <string, User>(userGroup.Key, userGroup);

                //create a new collection of groups
                UsersGrouped = new ObservableCollection <Grouping <string, User> >(sorted);
                OnPropertyChanged("UsersGroupeds");
            }
            catch (Exception ex)
            {
                var page = new ContentPage();
                page.DisplayAlert("Error", "Unable to load users.", "OK");;
            }
            finally
            {
                IsBusy = false;
            }
        }
コード例 #50
0
        private void ButtonAddTab_Clicked(object sender, EventArgs e)
        {
            var newTab = new ContentPage
            {
                Title   = "Tab sample",
                Content = new StackLayout
                {
                    VerticalOptions = LayoutOptions.Center,
                    Children        =
                    {
                        new Label
                        {
                            HorizontalTextAlignment = TextAlignment.Center,
                            Text = "Welcome to Xamarin Forms Tab sample!"
                        },
                    }
                }
            };

            _tabbedPage.Children.Add(newTab);

            TabBadge.SetBadgeText(newTab, "#1");
            TabBadge.SetBadgeColor(newTab, Color.Black);
        }
コード例 #51
0
        public async Task PushLifeCycle(bool useMaui)
        {
            ContentPage initialPage = new ContentPage();
            ContentPage pushedPage  = new ContentPage();

            ContentPage initialPageDisappear = null;
            ContentPage pageAppearing        = null;

            initialPage.Disappearing += (sender, _)
                                        => initialPageDisappear = (ContentPage)sender;

            pushedPage.Appearing += (sender, _)
                                    => pageAppearing = (ContentPage)sender;

            NavigationPage nav = new TestNavigationPage(useMaui, initialPage);

            _ = new Window(nav);
            nav.SendAppearing();

            await nav.PushAsync(pushedPage);

            Assert.AreEqual(initialPageDisappear, initialPage);
            Assert.AreEqual(pageAppearing, pushedPage);
        }
コード例 #52
0
        /// <summary>
        /// Display a Characteristics Page
        /// </summary>
        public void OnItemSelected(object sender, SelectedItemChangedEventArgs e)
        {
            if (((ListView)sender).SelectedItem == null)
            {
                return;
            }

            var         characteristic      = e.SelectedItem as ICharacteristic;
            ContentPage characteristicsPage = null;


            if (characteristic.ID == 0x2A37.UuidFromPartial() || characteristic.ID == 0x2A38.UuidFromPartial())
            {
                characteristicsPage = new CharacteristicDetail_Hrm(adapter, device, service, characteristic);
            }
            else
            {
                characteristicsPage = new CharacteristicDetail(adapter, device, service, characteristic);
            }

            Navigation.PushAsync(characteristicsPage);

            ((ListView)sender).SelectedItem = null;             // clear selection
        }
コード例 #53
0
        public async Task VisualPropagationShellLevel()
        {
            Shell       shell = new Shell();
            ContentPage page  = new ContentPage();

            shell.Items.Add(CreateShellItem(page));

            // setup title view
            StackLayout titleView = new StackLayout()
            {
                BackgroundColor = Colors.White
            };
            Button button = new Button();

            titleView.Children.Add(button);
            Shell.SetTitleView(page, titleView);
            IVisualController visualController = button as IVisualController;


            Assert.AreEqual(page, titleView.Parent);
            Assert.AreEqual(VisualMarker.Default, ((IVisualController)button).EffectiveVisual);
            shell.Visual = VisualMarker.Material;
            Assert.AreEqual(VisualMarker.Material, ((IVisualController)button).EffectiveVisual);
        }
コード例 #54
0
        void NavigateTo(OptionItem option)
        {
            if (previousItem != null)
            {
                previousItem.Selected = false;
            }

            option.Selected = true;
            previousItem    = option;

            var displayPage = PageForOption(option);

#if WINDOWS_PHONE
            Detail = new ContentPage();//work around to clear current page.
#endif
            var color = Helpers.Color.Blue.ToFormsColor();
            Detail = new NavigationPage(displayPage)
            {
                BarBackgroundColor = color,
                BarTextColor       = Color.White
            };

            IsPresented = false;
        }
コード例 #55
0
        public void TestAdd()
        {
            var menu = new NavigationMenu();

            bool signaled = false;

            menu.PropertyChanged += (sender, args) => {
                switch (args.PropertyName)
                {
                case "Targets":
                    signaled = true;
                    break;
                }
            };

            var child = new ContentPage {
                Content = new View(),
                Icon    = "img.jpg"
            };

            menu.Add(child);
            Assert.True(menu.Targets.Contains(child));
            Assert.True(signaled);
        }
コード例 #56
0
        //sets the content of the main page according to selected tab and checks for backbutton visibility
        public void UpdateContent()
        {
            ContentPage contemp = null;

            switch (currentCategory)
            {
            case CategoryType.NewsType:
                contemp = ((ContentPage)stack.NewsContent.CurrentPage);
                break;

            case CategoryType.PlayerType:
                contemp = ((ContentPage)stack.PlayerContent.CurrentPage);
                break;

            case CategoryType.MatchType:
                contemp = ((ContentPage)stack.MatchContent.CurrentPage);
                break;

            case CategoryType.TournamentType:
                contemp = ((ContentPage)stack.LeagueTableContent.CurrentPage);
                break;

            case CategoryType.HistoryType:
                contemp = ((ContentPage)stack.HistoryContent.CurrentPage);
                break;
            }
            if (contemp.Navigation.NavigationStack.Count == 1)
            {
                NotMainPage = false;
            }
            else
            {
                NotMainPage = true;
            }
            contentPage.Content = contemp.Content;
        }
コード例 #57
0
        public void TestLayoutChildrenCenter()
        {
            View child;
            var  page = new ContentPage
            {
                Content = child = new View
                {
                    WidthRequest      = 100,
                    HeightRequest     = 200,
                    HorizontalOptions = LayoutOptions.Center,
                    VerticalOptions   = LayoutOptions.Center,
                    IsPlatformEnabled = true
                },
                IsPlatformEnabled = true,
            };

            page.Layout(new Rectangle(0, 0, 800, 800));

            Assert.AreEqual(new Rectangle(350, 300, 100, 200), child.Bounds);

            page.Layout(new Rectangle(0, 0, 50, 50));

            Assert.AreEqual(new Rectangle(0, 0, 50, 50), child.Bounds);
        }
コード例 #58
0
 public PageOrientationEventArgs(PageOrientation orientation, ContentPage currentPage)
 {
     Orientation     = orientation;
     _oldOrientation = Orientation;
     if (Orientation == PageOrientation.Horizontal)
     {
         ScaleFontSizes("Landscape");
     }
     else
     {
         ScaleFontSizes("Portrait");
     }
     if (currentPage is OrientationContentPage && (currentPage is OnboardLandscape || currentPage is Onboard))
     {
         if (Orientation == PageOrientation.Horizontal)
         {
             Application.Current.MainPage = new OnboardLandscape(isFirstLoad: OrientationContentPage.firstPageLoad, boardPosition: OrientationContentPage.onboardPosition);
         }
         else
         {
             Application.Current.MainPage = new Onboard(OrientationContentPage.firstPageLoad, OrientationContentPage.onboardPosition);
         }
     }
 }
コード例 #59
0
        public async Task PopToRootRemovesMiddlePagesBeforePoppingVisibleModalPages()
        {
            Routing.RegisterRoute("ModalTestPage", typeof(ShellModalTests.ModalTestPage));
            TestShell testShell = new TestShell(
                CreateShellSection <NavigationMonitoringTab>(shellContentRoute: "rootpage")
                );

            var middlePage = new ContentPage();
            var tab        = (NavigationMonitoringTab)testShell.CurrentItem.CurrentItem;
            await testShell.Navigation.PushAsync(middlePage);

            await testShell.GoToAsync("ModalTestPage");

            tab.NavigationsFired.Clear();

            await testShell.GoToAsync("../..");

            Assert.That(testShell.CurrentState.Location.ToString(),
                        Is.EqualTo($"//rootpage"));

            Assert.AreEqual("OnRemovePage", tab.NavigationsFired[0]);
            Assert.AreEqual("OnPopModal", tab.NavigationsFired[1]);
            Assert.AreEqual(2, tab.NavigationsFired.Count);
        }
コード例 #60
0
        public async Task CurrentPageChanged()
        {
            var root = new ContentPage {
                Title = "Root"
            };
            var navPage = new NavigationPage(root);

            bool changing = false;

            navPage.PropertyChanging += (object sender, PropertyChangingEventArgs e) => {
                if (e.PropertyName == NavigationPage.CurrentPageProperty.PropertyName)
                {
                    Assert.That(navPage.CurrentPage, Is.SameAs(root));
                    changing = true;
                }
            };

            var next = new ContentPage {
                Title = "Next"
            };

            bool changed = false;

            navPage.PropertyChanged += (sender, e) => {
                if (e.PropertyName == NavigationPage.CurrentPageProperty.PropertyName)
                {
                    Assert.That(navPage.CurrentPage, Is.SameAs(next));
                    changed = true;
                }
            };

            await navPage.PushAsync(next);

            Assert.That(changing, Is.True, "PropertyChanging was not raised for 'CurrentPage'");
            Assert.That(changed, Is.True, "PropertyChanged was not raised for 'CurrentPage'");
        }