当前位置: 首页>>代码示例>>C#>>正文


C# ContentPage.DisplayAlert方法代码示例

本文整理汇总了C#中Xamarin.Forms.ContentPage.DisplayAlert方法的典型用法代码示例。如果您正苦于以下问题:C# ContentPage.DisplayAlert方法的具体用法?C# ContentPage.DisplayAlert怎么用?C# ContentPage.DisplayAlert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Xamarin.Forms.ContentPage的用法示例。


在下文中一共展示了ContentPage.DisplayAlert方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: 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;
        }
开发者ID:AjourMedia,项目名称:FootballTournament2014,代码行数:26,代码来源:TeamsViewModel.cs

示例2: 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;
			}
		}
开发者ID:richardboegli,项目名称:KinderChat,代码行数:27,代码来源:StatisticsNamesViewModel.cs

示例3: ExecuteLoadItemsCommand

        private void ExecuteLoadItemsCommand()
        {
            if (IsBusy)
                return;

            IsBusy = true;

            try
            {
                KnockoutMatches.Clear();
                var result = MatchService.GetKnockoutMatches();

                foreach (var item in result)
                {
                    KnockoutMatches.Add(item);
                }

            }
            catch (Exception)
            {
                var page = new ContentPage();
                page.DisplayAlert("Error", "Unable to load matches.", "OK", null);
            }

            IsBusy = false;
        }
开发者ID:AjourMedia,项目名称:FootballTournament2014,代码行数:26,代码来源:KnockoutMatchesViewModel.cs

示例4: ExecuteLoadFlagsCommand

		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;
			}
		}
开发者ID:richardboegli,项目名称:KinderChat,代码行数:33,代码来源:FlaggedUsersViewModel.cs

示例5: ExecuteLoadStatsCommand

		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;
			}
		}
开发者ID:richardboegli,项目名称:KinderChat,代码行数:31,代码来源:StatisticsViewModel.cs

示例6: ExecuteArticleCommand

    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();
    }
开发者ID:bencrispin,项目名称:ScrollInWeb,代码行数:25,代码来源:ArticleViewModel.cs

示例7: ExecuteLoadItemsCommand

		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;
		}
开发者ID:bsimser,项目名称:Hanselman.Forms,代码行数:28,代码来源:BlogFeedViewModel.cs

示例8: MainPage

        public MainPage()
        {
            button = new Button
            {
                Text = "Click me",
            };

            label = new Label
            {
                XAlign = TextAlignment.Center,
                Text = "Welcome to Xamarin Forms!"
            };
            button.Clicked += async (sender, e) =>
            {
                var data = "Cryptographic example";
                var pass = "MySecretKey";

                var contentPage = new ContentPage();
                var salt = Crypto.CreateSalt(16);
                await contentPage.DisplayAlert("Alert", "Encrypting String " + data + ", with salt " + BitConverter.ToString(salt), "OK");
                var bytes = Crypto.EncryptAes(data, pass, salt);
                await contentPage.DisplayAlert("Alert", "Encrypted, Now Decrypting", "OK");
                var str = Crypto.DecryptAes(bytes, pass, salt);
                await contentPage.DisplayAlert("Alert", "Decryted " + str, "OK");
            };

            this.Title = "Crypto Forms";
            // The root page of your application
            this.Content = new StackLayout
            {
                VerticalOptions = LayoutOptions.Center,
                Children =
                {
                    label,
                    button

                }
            };
        }
开发者ID:michaellperry,项目名称:CryptoForms,代码行数:39,代码来源:MainPage.cs

示例9: App

    public App()
    {
      var editField = new Entry
      {
        Placeholder = "Enter text for setting",
        Text = SettingsSample.Helpers.Settings.GeneralSettings
      };
      var buttonSave = new Button
      {
        Text = "Save Setting"
      };

      var buttonGet = new Button
      {
        Text = "Get Setting"
      };
      // The root page of your application
      MainPage = new ContentPage
      {
        Content = new StackLayout
        {
          VerticalOptions = LayoutOptions.Center,
          Children = {
						new Label {
							XAlign = TextAlignment.Center,
							Text = "Enter value to save to settings:"
						}, editField,
            buttonSave,
            buttonGet
					}
        }
      };

      buttonSave.Clicked += (sender, args) =>
        {
          SettingsSample.Helpers.Settings.GeneralSettings = editField.Text;
        };

      buttonGet.Clicked += (sender, args) =>
        {
          MainPage.DisplayAlert("Current Value:", SettingsSample.Helpers.Settings.GeneralSettings, "OK");
        };
    }
开发者ID:charifield,项目名称:Xamarin.Plugins,代码行数:43,代码来源:App.cs

示例10: ExecuteLoadStatsCommand

		public async Task ExecuteLoadStatsCommand()
		{
			if (IsBusy)
				return;

			IsBusy = true;

			try
			{
				var adminManager = new AdminManager(Settings.AccessToken);
				var avatarManager = new AvatarManager(Settings.AccessToken);
				Count = await adminManager.TotalAvatarCount();
				var avas = await avatarManager.GetStaticAvatars();
				Avatars.Clear();
				var items = await adminManager.PopularAvatars();
				foreach(var avatar in items.OrderByDescending(a => a.Count))
				{
					var myava = avas.FirstOrDefault(a => a.Id == avatar.AvatarId);

					if (myava == null)
						continue;

					Avatars.Add(new MyAvatar
						{
							Count = avatar.Count.ToString(),
							Location = myava.Location,
							Url = EndPoints.BaseUrl + myava.Location
						});
				}
			}
			catch (Exception ex)
			{
				var page = new ContentPage();
				page.DisplayAlert("Error", "Unable to load.", "OK"); ;
			}
			finally
			{
				IsBusy = false;
			}
		}
开发者ID:richardboegli,项目名称:KinderChat,代码行数:40,代码来源:StatisticsAvatarsViewModel.cs

示例11: ExecuteLoadItemsCommand

		private async Task ExecuteLoadItemsCommand()
		{
			if (IsBusy)
				return;

			IsBusy = true;

			try{
				/*
				var items = App.WorkManager.GetWorkItems();
				foreach(var item in items)
				{
					workItems.Add(item);
				}
				*/
			} catch (Exception ex) {
				var page = new ContentPage();
				var result = page.DisplayAlert ("Error", "Unable to load work items.", "OK");
			}

			IsBusy = false;
		}
开发者ID:jacobduijzer,项目名称:WerktijdenApp,代码行数:22,代码来源:HomePageViewModel.cs

示例12: App

        public App()
        {
            var loginButton = new Button { Text = "Login", StyleId = "loginButton" };

            var mainPage = new ContentPage {
                Content = new StackLayout {
                    VerticalOptions = LayoutOptions.Center,
                    HorizontalOptions = LayoutOptions.Center,
                    Children = {
                        new Entry { Placeholder = "Username", StyleId = "username" },
                        new Entry { Placeholder = "Password", StyleId = "password" },
                        loginButton
                    }
                }
            };

            loginButton.Clicked += async (object sender, EventArgs e) => {
                await mainPage.DisplayAlert ("Login", "Logged In", "OK");
            };
            // The root page of your application
            MainPage = mainPage;
        }
开发者ID:paulpatarinski,项目名称:XamUITest_Examples,代码行数:22,代码来源:Xamarin_Forms.cs

示例13: App

		// --------------------------------------------------------------------------
		//
		// CONSTRUCTORS
		//
		// --------------------------------------------------------------------------
		public App () {
			// Create the orange image that goes on the main screen of the app
			var orangeImage = new CustomImage { Aspect = Aspect.Fill };
			orangeImage.Source = "orange_square.png";

			// Create a ContentPage to use as the view of the app.
			var page = new ContentPage {
				Content = new StackLayout {
					VerticalOptions = LayoutOptions.Center,
					Children = { orangeImage }
				}
			};

			// When the image dispatches a tap event (custom event, see CustomImage.cs),
			// then display an alert.
			orangeImage.TapEvent += (object sender, PointEventArgs e) => {
				page.DisplayAlert("Tap!", String.Format("({0}, {1})", e.X, e.Y), "Cancel");
			};

			// Set the main page of the app.
			MainPage = page;
		}
开发者ID:biyyalakamal,项目名称:customer-success-samples,代码行数:27,代码来源:FormsImageTapGesture.cs

示例14: ExecuteLoadItemsCommand

        private async Task ExecuteLoadItemsCommand()
        {
            if (IsBusy)
                return;

            IsBusy = true;

            try
            {
                Result.Clear();
                using(var httpClient = new HttpClient())
                {
                    for (int i = 1; i <= 15; i++)
                    {
                        var feed = string.Format("http://footballdb.herokuapp.com/api/v1/event/world.2014/round/{0}",i);
                        var responseString = await httpClient.GetStringAsync(feed);
                        Result.AddRange(MatchService.GetMatchDay(responseString));
                    }

                    foreach(var item in Result)
                    {
                        item.HomeScore = (item.HomeScore == "" || item.HomeScore == null) ?
                            "0" : item.HomeScore;
                        item.AwayScore = (item.AwayScore == "" || item.AwayScore == null) ?
                            "0" : item.AwayScore;
                    }
                }
                this.ItemsLoaded(this, new EventArgs());
            } 
            catch (Exception) 
            {
                var page = new ContentPage();
                page.DisplayAlert ("Error", "Unable to load matches.", "OK", null);
            }

            IsBusy = false;
        }
开发者ID:AjourMedia,项目名称:FootballTournament2014,代码行数:37,代码来源:GroupMatchesViewModel.cs

示例15: ExecuteLoadItemsCommand

        private async Task ExecuteLoadItemsCommand()
        {
            if (IsBusy)
                return;

            IsBusy = true;
            var error = false;
            try
            {
                var httpClient = new HttpClient();
				var feed = "http://blog.appointy.com/feed/";

                var responseString = await httpClient.GetStringAsync(feed);

                FeedItems.Clear();
                var items = await ParseFeed(responseString);
                foreach (var feedItem in items)
                {
                    FeedItems.Add(feedItem);
                }
            }
            catch
            {
                error = true;
            }

            if (error)
            {
                var page = new ContentPage();
                var result = page.DisplayAlert("Oops!", "Unable to load .", "OK");

            }


            IsBusy = false;
        }
开发者ID:Shankulkarni,项目名称:AppointyBlog,代码行数:36,代码来源:PodcastViewModel.cs


注:本文中的Xamarin.Forms.ContentPage.DisplayAlert方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。