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


C# ContentDialog.Hide方法代码示例

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


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

示例1: CallAppService

        private async void CallAppService()
        {
            await EnsureConnectionToService();

            //Send data to the service 
            var message = new ValueSet();
            message.Add("Command", "CalcSum");
            message.Add("Value1", Int32.Parse(Value1.Text));
            message.Add("Value2", Int32.Parse(Value2.Text));

            //Send a message  
            AppServiceResponse response = await connection.SendMessageAsync(message);
            if (response.Status == AppServiceResponseStatus.Success)
            {
                int sum = (int)response.Message["Result"];
                var cd = new ContentDialog();
                cd.Title = "Result=" + sum;
                cd.PrimaryButtonText = "OK";
                cd.PrimaryButtonClick += (s, a) => cd.Hide();
                cd.ShowAsync();
            }
        }
开发者ID:MuffPotter,项目名称:201505-MVA,代码行数:22,代码来源:MainPage.xaml.cs

示例2: DisplaySynonymsResponse

        private async System.Threading.Tasks.Task DisplaySynonymsResponse(SynonymsServiceClientLibrary.SynonymsServiceResponse synonymsResponse)
        {
            string synonymsOutput = "";
            if (synonymsResponse.Status == AppServiceResponseStatus.Success)
            {
                foreach (var item in synonymsResponse.Synonyms)
                {
                    synonymsOutput += "|" + item;
                }

                var cd = new ContentDialog();
                cd.Title = "Synonyms=" + synonymsOutput;
                cd.PrimaryButtonText = "OK";
                cd.PrimaryButtonClick += (s, a) => cd.Hide();
                await cd.ShowAsync();
            }
            else
            {
                await new MessageDialog("Synonyms API call failed").ShowAsync();
            }
        }
开发者ID:MuffPotter,项目名称:201505-MVA,代码行数:21,代码来源:MainPage.xaml.cs

示例3: Prompt

        public override void Prompt(PromptConfig config)
        {
            var dialog = new ContentDialog { Title = config.Title };
            var txt = new TextBox {
                PlaceholderText = config.Placeholder,
                Text = config.Text ?? String.Empty
            };
            var stack = new StackPanel {
                Children = {
                    new TextBlock { Text = config.Message },
                    txt
                }
            };
            dialog.Content = stack;

            dialog.PrimaryButtonText = config.OkText;
            dialog.PrimaryButtonCommand = new Command(() => {
                config.OnResult?.Invoke(new PromptResult {
                    Ok = true,
                    Text = txt.Text.Trim()
                });
                dialog.Hide();
            });

            if (config.IsCancellable) {
                dialog.SecondaryButtonText = config.CancelText;
                dialog.SecondaryButtonCommand = new Command(() => {
                    config.OnResult?.Invoke(new PromptResult {
                        Ok = false,
                        Text = txt.Text.Trim()
                    });
                    dialog.Hide();
                });
            }
            dialog.ShowAsync();
        }
开发者ID:benoitjadinon,项目名称:userdialogs,代码行数:36,代码来源:UserDialogsImpl.cs

示例4: NewGameButton_Click

        /// <summary>
        /// Handles starting of a new game. Shows new game dialogs and creates a new game object.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void NewGameButton_Click(object sender, RoutedEventArgs e)
        {
            var content = new ContentDialog()
            {
                Title = "New Game",
                Content = "What kind of game would you like to play?\r\n(Sorry, you actually have no choice as we didn't get to implement networked games)",
                PrimaryButtonText = "Local",
                SecondaryButtonText = "Network",
                IsSecondaryButtonEnabled = false
            };

            //Local game nested ass lambdas
            content.PrimaryButtonClick += async (dialog, args) =>
            {
                content.Hide();
                var a = new LocalGameDialog();
                a.PrimaryButtonClick += async (contentDialog, eventArgs) =>
                {
                    var c = contentDialog as LocalGameDialog;
                    if (c.PlayerNames.Count(p => p.Text == string.Empty) > 4)
                    {
                        a.Hide();
                        await new MessageDialog("At least 2 players must be added").ShowAsync();
                        NewGameButton_Click(this, null);
                    }
                    else
                    {
                        var players = new List<Player>();
                        foreach (var p in c.PlayerNames.Where(p => p.Text != string.Empty))
                        {
                            System.Diagnostics.Debug.WriteLine("Adding player: " + p.Text);
                            players.Add(new Player() {Name = p.Text});
                        }
                        InitGame(players);
                    }
                };
                a.SecondaryButtonClick += (sender1, clickEventArgs) =>
                {
                    a.Hide();
                    NewGameButton_Click(this, null);
                };
                await a.ShowAsync();
            };
            await content.ShowAsync();
        }
开发者ID:UnknownJoe796,项目名称:2Risky,代码行数:50,代码来源:MainPage.xaml.cs

示例5: Toast

        public override void Toast(ToastConfig config)
        {
            // TODO: action text and action command will work here!
            var stack = new StackPanel { Orientation = Orientation.Horizontal };
            if (config.Icon != null) {
                var icon = config.Icon.ToNative();
                stack.Children.Add(new Image { Source = icon });
            }
            stack.Children.Add(new TextBlock {
                Text = config.Text,
                Foreground = new SolidColorBrush(config.TextColor.ToNative())
            });

            var dialog = new ContentDialog {
                Content = stack,
                Background = new SolidColorBrush(config.BackgroundColor.ToNative())
            };
            dialog.Tapped += (sender, args) => {
                dialog.Hide();
                config.Action?.Invoke();
            };
            dialog.ShowAsync();
            Task.Delay(config.Duration)
                .ContinueWith(x => {
                    try {
                        dialog.Hide();
                    }
                    catch { } // swallow race condition
                });
        }
开发者ID:benoitjadinon,项目名称:userdialogs,代码行数:30,代码来源:UserDialogsImpl.cs

示例6: Show

 void Show(IBitmap image, string message, Color bgColor, int timeoutMillis)
 {
     var cd = new ContentDialog {
         Background = new SolidColorBrush(bgColor.ToNative()),
         Content = new TextBlock { Text = message }
     };
     cd.ShowAsync();
     Task.Delay(TimeSpan.FromMilliseconds(timeoutMillis)).ContinueWith(x => cd.Hide());
 }
开发者ID:benoitjadinon,项目名称:userdialogs,代码行数:9,代码来源:UserDialogsImpl.cs

示例7: OnPageActionSheet

		async void OnPageActionSheet(Page sender, ActionSheetArguments options)
		{
			List<string> buttons = options.Buttons.ToList();

			var list = new Windows.UI.Xaml.Controls.ListView
			{
				Style = (Windows.UI.Xaml.Style)Windows.UI.Xaml.Application.Current.Resources["ActionSheetList"],
				ItemsSource = buttons,
				IsItemClickEnabled = true
			};

			var dialog = new ContentDialog
			{
				Template = (Windows.UI.Xaml.Controls.ControlTemplate)Windows.UI.Xaml.Application.Current.Resources["MyContentDialogControlTemplate"],
				Content = list,
				Style = (Windows.UI.Xaml.Style)Windows.UI.Xaml.Application.Current.Resources["ActionSheetStyle"]
			};

			if (options.Title != null)
				dialog.Title = options.Title;

			list.ItemClick += (s, e) =>
			{
				dialog.Hide();
				options.SetResult((string)e.ClickedItem);
			};

			TypedEventHandler<CoreWindow, CharacterReceivedEventArgs> onEscapeButtonPressed = delegate(CoreWindow window, CharacterReceivedEventArgs args)
			{
				if (args.KeyCode == 27)
				{
					dialog.Hide();
					options.SetResult(ContentDialogResult.None.ToString());
				}
			};

			Window.Current.CoreWindow.CharacterReceived += onEscapeButtonPressed;

			_actionSheetOptions = options;

			if (options.Cancel != null)
				dialog.SecondaryButtonText = options.Cancel;

			if (options.Destruction != null)
				dialog.PrimaryButtonText = options.Destruction;

			ContentDialogResult result = await dialog.ShowAsync();
			if (result == ContentDialogResult.Secondary)
				options.SetResult(options.Cancel);
			else if (result == ContentDialogResult.Primary)
				options.SetResult(options.Destruction);

			Window.Current.CoreWindow.CharacterReceived -= onEscapeButtonPressed;
		}
开发者ID:cosullivan,项目名称:Xamarin.Forms,代码行数:54,代码来源:Platform.cs

示例8: Show

        /// <summary>
        /// Shows the dialog. It takes <see cref="InputDialogViewModel"/> to populate the system dialog. It also sets the first command to be 
        /// the default and last one to be the cancel command.
        /// </summary>
        /// <param name="viewType"> Type of dialog control. </param>
        public async void Show(Type viewType)
        {
            this.Initialize();

            var dialog = new ContentDialog
            {
                Title = this.ViewModel.ActivationData.Title,
                MaxWidth = Window.Current.CoreWindow.Bounds.Width
            };

            var panel = new StackPanel();
            panel.Children.Add(new TextBlock
            {
                Text = this.ViewModel.ActivationData.Message,
                TextWrapping = TextWrapping.Wrap,
                Margin = new Thickness(0, 6, 0, 12)
            });

            var tb = new TextBox
            {
                Text = this.ViewModel.ActivationData.Text
            };

            panel.Children.Add(tb);
            
            var primaryText = this.ViewModel.ActivationData.Commands.FirstOrDefault() ?? "Ok";
            var secondaryText = this.ViewModel.ActivationData.Commands.Skip(1).FirstOrDefault() ?? string.Empty;
            var returnValue = secondaryText;

            tb.KeyUp += (sender, args) =>
            {
                if (args.Key == VirtualKey.Enter)
                {
                    returnValue = primaryText;
                    dialog.Hide();
                }
            };

            dialog.Content = panel;
            dialog.PrimaryButtonText = primaryText;
            dialog.SecondaryButtonText = secondaryText;

            tb.SelectionStart = tb.Text.Length;
            tb.Focus(FocusState.Programmatic);

            try
            {
                this.dialogTask = dialog.ShowAsync();
                var result = await this.dialogTask;
                var resultValue = string.Empty;

                this.dialogTask = null;
                switch (result)
                {
                    case ContentDialogResult.None:
                        resultValue = returnValue;
                        break;
                    case ContentDialogResult.Primary:
                        resultValue = primaryText;
                        break;
                    case ContentDialogResult.Secondary:
                        resultValue = secondaryText;
                        break;
                }

                await this.NavigationService.GoBackAsync(new InputDialogResult(resultValue, tb.Text));
            }
            catch (TaskCanceledException ex)
            {
                // Happens when you call nanavigationSerivce.GoBack(...) while the dialog is still open.
            }
        }
开发者ID:bezysoftware,项目名称:MVVM-Dialogs,代码行数:77,代码来源:InputDialogContainer.cs

示例9: SetPasswordPrompt

        void SetPasswordPrompt(ContentDialog dialog, StackPanel stack, PromptConfig config)
        {
            var txt = new PasswordBox
            {
                PlaceholderText = config.Placeholder,
                Password = config.Text ?? String.Empty
            };
            stack.Children.Add(txt);

            dialog.PrimaryButtonCommand = new Command(() =>
            {
                config.OnResult?.Invoke(new PromptResult
                {
                    Ok = true,
                    Text = txt.Password
                });
                dialog.Hide();
            });
        }
开发者ID:GustavoTancredo,项目名称:userdialogs,代码行数:19,代码来源:UserDialogsImpl.cs

示例10: Prompt

        public override void Prompt(PromptConfig config)
        {
            var stack = new StackPanel
            {
                Children =
                {
                    new TextBlock { Text = config.Message }
                }
            };
            var dialog = new ContentDialog
            {
                Title = config.Title,
                Content = stack,
                PrimaryButtonText = config.OkText
            };

            if (config.InputType == InputType.Password)
                this.SetPasswordPrompt(dialog, stack, config);
            else
                this.SetDefaultPrompt(dialog, stack, config);

            if (config.IsCancellable) {
                dialog.SecondaryButtonText = config.CancelText;
                dialog.SecondaryButtonCommand = new Command(() =>
                {
                    config.OnResult?.Invoke(new PromptResult { Ok = false });
                    dialog.Hide();
                });
            }

            this.Dispatch(() => dialog.ShowAsync());
        }
开发者ID:GustavoTancredo,项目名称:userdialogs,代码行数:32,代码来源:UserDialogsImpl.cs

示例11: Show

        protected virtual void Show(IBitmap image, string message, Color bgColor, int timeoutMillis)
        {
            var stack = new StackPanel
            {
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment = VerticalAlignment.Center,
                Opacity = 0.7
            };
            if (image != null)
            {
                var source = image.ToNative();
                stack.Children.Add(new Image { Source = source });
            }
            stack.Children.Add(new TextBlock
            {
                Text = message,
                FontSize = 24f,
                TextAlignment = TextAlignment.Center,
                FontWeight = FontWeights.Bold
            });

            var cd = new ContentDialog
            {
                Background = new SolidColorBrush(bgColor.ToNative()),
                BorderBrush = new SolidColorBrush(bgColor.ToNative()),
                Content = stack
            };
            stack.Tapped += (sender, args) => cd.Hide();

            this.Dispatch(() => cd.ShowAsync());
            Task.Delay(TimeSpan.FromMilliseconds(timeoutMillis))
                .ContinueWith(x => this.Dispatch(cd.Hide));
        }
开发者ID:philippd,项目名称:userdialogs,代码行数:33,代码来源:UserDialogsImpl.cs

示例12: SetPasswordPrompt

        protected virtual void SetPasswordPrompt(ContentDialog dialog, StackPanel stack, PromptConfig config)
        {
            var txt = new PasswordBox
            {
                PlaceholderText = config.Placeholder ?? String.Empty,
                Password = config.Text ?? String.Empty
            };
            if (config.MaxLength != null)
                txt.MaxLength = config.MaxLength.Value;

            stack.Children.Add(txt);
            dialog.PrimaryButtonCommand = new Command(() =>
            {
                config.OnAction?.Invoke(new PromptResult(true, txt.Password));
                dialog.Hide();
            });
        }
开发者ID:philippd,项目名称:userdialogs,代码行数:17,代码来源:UserDialogsImpl.cs

示例13: Prompt

        public override IDisposable Prompt(PromptConfig config)
        {
            var stack = new StackPanel();
            if (!String.IsNullOrWhiteSpace(config.Message))
                stack.Children.Add(new TextBlock { Text = config.Message, TextWrapping = TextWrapping.WrapWholeWords });

            var dialog = new ContentDialog
            {
                Title = config.Title ?? String.Empty,
                Content = stack,
                PrimaryButtonText = config.OkText
            };

            if (config.InputType == InputType.Password)
                this.SetPasswordPrompt(dialog, stack, config);
            else
                this.SetDefaultPrompt(dialog, stack, config);

            if (config.IsCancellable)
            {
                dialog.SecondaryButtonText = config.CancelText;
                dialog.SecondaryButtonCommand = new Command(() =>
                {
                    config.OnAction?.Invoke(new PromptResult(false, String.Empty));
                    dialog.Hide();
                });
            }

            return this.DispatchAndDispose(
                () => dialog.ShowAsync(),
                dialog.Hide
            );
        }
开发者ID:philippd,项目名称:userdialogs,代码行数:33,代码来源:UserDialogsImpl.cs

示例14: C_PrimaryButtonClick

 private void C_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
 {
     sender.Hide();
 }
开发者ID:mtwn105,项目名称:PDFMe-Windows-10,代码行数:4,代码来源:History.xaml.cs

示例15: OnPageActionSheet

		async void OnPageActionSheet(Page sender, ActionSheetArguments options)
		{
			List<string> buttons = options.Buttons.ToList();

			var list = new Windows.UI.Xaml.Controls.ListView
			{
				Style = (Windows.UI.Xaml.Style)Windows.UI.Xaml.Application.Current.Resources["ActionSheetList"],
				ItemsSource = buttons,
				IsItemClickEnabled = true
			};

			var dialog = new ContentDialog
			{
				Template = (Windows.UI.Xaml.Controls.ControlTemplate)Windows.UI.Xaml.Application.Current.Resources["MyContentDialogControlTemplate"],
				Content = list,
				Style = (Windows.UI.Xaml.Style)Windows.UI.Xaml.Application.Current.Resources["ActionSheetStyle"]
			};

			if (options.Title != null)
				dialog.Title = options.Title;

			list.ItemClick += (s, e) =>
			{
				dialog.Hide();
				options.SetResult((string)e.ClickedItem);
			};

			_actionSheetOptions = options;

			if (options.Cancel != null)
				dialog.SecondaryButtonText = options.Cancel;

			if (options.Destruction != null)
				dialog.PrimaryButtonText = options.Destruction;

			ContentDialogResult result = await dialog.ShowAsync();
			if (result == ContentDialogResult.Secondary)
				options.SetResult(options.Cancel);
			else if (result == ContentDialogResult.Primary)
				options.SetResult(options.Destruction);
		}
开发者ID:Costo,项目名称:Xamarin.Forms,代码行数:41,代码来源:Platform.cs


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