本文整理汇总了C#中ContentPage类的典型用法代码示例。如果您正苦于以下问题:C# ContentPage类的具体用法?C# ContentPage怎么用?C# ContentPage使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ContentPage类属于命名空间,在下文中一共展示了ContentPage类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Init
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();
};
}
示例2: TestCase001
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 ());
}
示例3: RootMDPNavigationContentPage
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)
});
}
示例4: TestNavigationImplPop
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);
}
示例5: BindData
/// <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
}
}
示例6: Init
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");
}
示例7: OnMenuSelected
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;
}
示例8: Edit
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 fucking error while saving. Fuck 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();
}
示例9: RootTabbedNavigationContentPage
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);
}
示例10: Run
/// <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);
}
}
示例11: SimpleApp
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();
}
示例12: ConverterIsInvoked
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);
}
示例13: Index
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();
}
}
示例14: RootMDPNavigationTabbedContentPage
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"
};
}
示例15: BindingCanNotBeReused
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"));
}