/// <summary> /// Display the CustomInputDialog on screen with the specified parameter from the constructor /// </summary> public void ShowDialog() { // Create the base canvas that will hold all the controls and application bar functions DialogWindow = new RadModalWindow() { Name = "CustomInputDialog", ApplicationBarInfo = new ApplicationBarInfo() { Buttons = { CreateOkButton(), // Default ok button with check icon CreateCancelButton(), // Default cancel button with cross icon } }, Background = new SolidColorBrush((Color)Application.Current.Resources["PhoneChromeColor"]), IsFullScreen = true, WindowSizeMode = WindowSizeMode.FitToPlacementTarget, VerticalContentAlignment = VerticalAlignment.Stretch, HorizontalContentAlignment = HorizontalAlignment.Stretch, IsClosedOnOutsideTap = false, // Only close on back button press or cancel button tap OpenAnimation = AnimationService.GetOpenDialogAnimation(), }; // When the open animation of the dialog has ended, select a text selection if specified // Do this after the animation because else the dialog will be pushed to far up by the default // behavior of the focus action on a textbox by the WP OS when keyboard slides in DialogWindow.OpenAnimation.Ended += (sender, args) => { // If specified make a default text selection so the user can do his action more quickly if (_settings.SelectDefaultText) { SetTextSelection(InputControl, _settings.DefaultText, _settings.IgnoreExtensionInSelection); } // Focus to make the selection visible and push up the keyboard immediately InputControl.Focus(); }; DialogWindow.WindowOpening += (sender, args) => DialogService.DialogOpening(args); DialogWindow.WindowClosed += (sender, args) => DialogService.DialogClosed(); // Create a Grid to populate with UI controls var mainGrid = new Grid() { HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch, RowDefinitions = { new RowDefinition() { Height = GridLength.Auto }, // Title row new RowDefinition() { Height = GridLength.Auto }, // Message row new RowDefinition() { Height = GridLength.Auto }, // Input control row }, Margin = new Thickness(24, 0, 24, 0) }; // Create title label var title = new TextBlock() { Text = _title.ToUpper(), // The specified title string in uppercase always FontFamily = new FontFamily("Segoe WP Semibold"), FontSize = Convert.ToDouble(Application.Current.Resources["PhoneFontSizeMediumLarge"]), Foreground = new SolidColorBrush((Color)Application.Current.Resources["PhoneForegroundColor"]), Margin = new Thickness(0, 28, 0, 0), HorizontalAlignment = HorizontalAlignment.Left, TextWrapping = TextWrapping.Wrap }; // Add title to the view mainGrid.Children.Add(title); Grid.SetRow(title, 0); // Create message label var message = new TextBlock() { Text = _message, // The specified message FontFamily = new FontFamily("Segoe WP SemiLight"), FontSize = Convert.ToDouble(Application.Current.Resources["PhoneFontSizeSmall"]), Foreground = new SolidColorBrush((Color)Application.Current.Resources["PhoneSubtleColor"]), Margin = new Thickness(0, 50, 0, 22), HorizontalAlignment = HorizontalAlignment.Left, TextWrapping = TextWrapping.Wrap }; // Add message to the view mainGrid.Children.Add(message); Grid.SetRow(message, 1); // Create input control InputControl = new TextBox() { Text = _settings.DefaultText, // The specified default text in the textbox control input area HorizontalAlignment = HorizontalAlignment.Stretch, Margin = new Thickness(-12) // Compensate for WP default padding }; // Add input to the view mainGrid.Children.Add(InputControl); Grid.SetRow(InputControl, 2); // Set the content on the canvas and show the dialog DialogWindow.Content = mainGrid; DialogWindow.IsOpen = true; }