예제 #1
0
        async void OnPageAlert(Page sender, AlertArguments options)
        {
            string content = options.Message ?? options.Title ?? string.Empty;

            LightContentDialog dialog = new LightContentDialog();

            if (options.Message == null || options.Title == null)
            {
                dialog.Content = content;
            }
            else
            {
                dialog.Title   = options.Title;
                dialog.Content = options.Message;
            }

            if (options.Accept != null)
            {
                dialog.IsPrimaryButtonEnabled = true;
                dialog.PrimaryButtonText      = options.Accept;
            }

            if (options.Cancel != null)
            {
                dialog.IsSecondaryButtonEnabled = true;
                dialog.SecondaryButtonText      = options.Cancel;
            }

            var dialogResult = await dialog.ShowAsync();

            options.SetResult(dialogResult == LightContentDialogResult.Primary);
        }
예제 #2
0
        async void OnPageActionSheet(Page sender, ActionSheetArguments options)
        {
            var list = new System.Windows.Controls.ListView
            {
                Style       = (System.Windows.Style)System.Windows.Application.Current.Resources["ActionSheetList"],
                ItemsSource = options.Buttons
            };

            var dialog = new LightContentDialog
            {
                Content = list,
            };

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

            list.SelectionChanged += (s, e) =>
            {
                if (list.SelectedItem != null)
                {
                    dialog.Hide();
                    options.SetResult((string)list.SelectedItem);
                }
            };

            /*_page.KeyDown += (window, e) =>
             * {
             *       if (e.Key == System.Windows.Input.Key.Escape)
             *       {
             *               dialog.Hide();
             *               options.SetResult(LightContentDialogResult.None.ToString());
             *       }
             * };*/

            if (options.Cancel != null)
            {
                dialog.IsSecondaryButtonEnabled = true;
                dialog.SecondaryButtonText      = options.Cancel;
            }

            if (options.Destruction != null)
            {
                dialog.IsPrimaryButtonEnabled = true;
                dialog.PrimaryButtonText      = options.Destruction;
            }

            LightContentDialogResult result = await dialog.ShowAsync();

            if (result == LightContentDialogResult.Secondary)
            {
                options.SetResult(options.Cancel);
            }
            else if (result == LightContentDialogResult.Primary)
            {
                options.SetResult(options.Destruction);
            }
        }