本文整理汇总了C#中Xamarin.Forms.ContentPage类的典型用法代码示例。如果您正苦于以下问题:C# ContentPage类的具体用法?C# ContentPage怎么用?C# ContentPage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ContentPage类属于Xamarin.Forms命名空间,在下文中一共展示了ContentPage类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreatePage
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;
}
示例2: App
public App()
{
// The root page of your application
MainPage = new ContentPage {
};
}
示例3: App
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
}
}
};
}
示例4: CreateMenuPage
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" };
}
示例5: ApplicationProviderMock
public ApplicationProviderMock()
{
MainPage = new ContentPage()
{
Title = "MainPage"
};
}
示例6: changeVisiblePage
public void changeVisiblePage(ContentPage page)
{
NavigationPage navPage = new NavigationPage(page);
navPage.BarBackgroundColor = Theme.getBackgroundColor ();
navPage.BarTextColor = Theme.getTextColor();
App.Current.MainPage = navPage;
}
示例7: App
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
}
}
};
}
示例8: LoginXaml
public LoginXaml (ContentPage parent)
{
InitializeComponent ();
viewModel = new LoginViewModel ();
this.parent = parent;
BindingContext = viewModel;
}
示例9: GetMainPage
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;
}
示例10: MainPage
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);
}
示例11: GetCategoryCell
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;
}
示例12: ExecuteLoadItemsCommand
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;
}
示例13: App
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);
}
示例14: ExecuteLoadStatsCommand
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;
}
}
示例15: App
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;
}
开发者ID:ardiprakasa,项目名称:create-cross-platform-mobile-apps-with-xamarinforms,代码行数:27,代码来源:XamarinFormsViews.cs