Telerik UI for Windows Phone by Progress

This topic demonstrates how to start using RadInputPrompt for Windows Phone.

To start using RadInputPrompt, the first thing that has to be done is adding references to the required assemblies:

  • Telerik.Windows.Core.dll
  • Telerik.Windows.Controls.Primitives.dll

The API of RadInputPrompt is very simple and similar to RadMessageBox's. It consists of a static Show method with a few overloads. There is also a static Close method that closes the currently opened input promt. The simplest use of RadInputPrompt is:

CopyC#
RadInputPrompt.Show("Title");

Probably you'd like to see what input the user has entered. The value goes to the InputPromptClosedEventArgs. Here is an example of getting the input and setting it to a property:

CopyC#
RadInputPrompt.Show("Title", closedHandler: (args) => { this.Name = args.Text; });

Below are all of the Show overloads with detailed explanations for each argument along with code examples.

Note

In RadInputPrompt for Windows Phone 8, you can use all of these Show methods with their async implementation. The async implementation allows you to await the call and write your logic that should be executed after the prompt is closed in a more straightforward way. The async overloads are practically the same as their not-async counterparts with the closedHanler argument omitted. Here is the previous example with the async implementation:

CopyC#
InputPromptClosedEventArgs args = await RadInputPrompt.ShowAsync("Title");
this.Name = args.Text;

And here are the possible overloads for the Show method:

CopyC#
public static void Show(
    object title,
    MessageBoxButtons buttons = MessageBoxButtons.OK,
    object message = null,
    InputMode inputMode = InputMode.Text,
    Style inputStyle = null,
    object checkBoxContent = null,
    bool isCheckBoxChecked = false,
    bool vibrate = true,
    HorizontalAlignment horizontalAlignment = HorizontalAlignment.Stretch,
    VerticalAlignment verticalAlignment = VerticalAlignment.Top,
    Action<InputPromptClosedEventArgs> closedHandler = null,
    Action<KeyEventArgs> keyDownHandler = null)

The first argument, title, is of type object because it is set internally as the content of a content control. It is a required argument as there is no default value for it. The message of the input prompt and the content of the check box are also of type object for the same reason.

The second argument is an enumeration with pre-defined button configurations. It can have the following values: OK, OKCancel, Yes and YesNo.

The third argument is the message that is used as content in the control.

The inputMode argument is an enumeration specifying whether the input field will be of type RadTextBox or RadPasswordBox. The possible values are: Text and Password.

Next is inputStyle which can be used to customize the inputField. If the inputMode is Text, the style should have a target type of RadTextBox and if inputMode is Password, the target type should be RadPasswordBox.

The isCheckBoxChecked argument is a Boolean value that determines the initial checked state of the check box.

The next argument is also a Boolean value that determines if the device will vibrate when the input prompt is shown.

The next two arguments specify the horizontal and vertical alignment of the input prompt on the device screen.

The last two arguments are callbacks. The closedHandler will be executed when the input prompt is closed and the keyDownHandler everytime a key is pressed. The closedHandler provides information for the input which was entered by the user, which button was clicked, whether the check box was Checked, the index of the clicked button in its parent panel and the overall input prompt result. The keyDown handler can be used in order to provide different behavior for pressing different buttons, for example close the prompt on enter.

CopyC#
public static void Show(
    IEnumerable<object> buttonsContent,
    object title,
    object message = null,
    InputMode inputMode = InputMode.Text,
    Style inputStyle = null,
    object checkBoxContent = null,
    bool isCheckBoxChecked = false,
    bool vibrate = false,
    HorizontalAlignment horizontalAlignment = HorizontalAlignment.Stretch,
    VerticalAlignment verticalAlignment = VerticalAlignment.Top,
    Action<InputPromptClosedEventArgs> closedHandler = null,
    Action<KeyEventArgs> keyDownHandler = null)

This overload is similar to the previous one and the only difference is the order of some arguments and the buttonsContent argument. It is of type IEnumerable<object>. This enumerable contains the content of the buttons that will be displayed. This enumerable can contain any number of objects of any type which will be mapped to the buttons in the input box. This is why in this overload there is no buttons argument.

CopyC#
public static void Show(
    DataTemplate buttonsTemplate,
    object title,
    IEnumerable<object> buttonsContent,
    object message = null,
    InputMode inputMode = InputMode.Text,
    Style inputStyle = null,
    object checkBoxContent = null,
    bool isCheckBoxChecked = false,
    bool vibrate = false,
    HorizontalAlignment horizontalAlignment = HorizontalAlignment.Stretch,
    VerticalAlignment verticalAlignment = VerticalAlignment.Top,
    Action<InputPromptClosedEventArgs> closedHandler = null,
    Action<KeyEventArgs> keyDownHandler = nul)

This overload differs from the others in the buttonsTemplate argument which is of type DataTemplate. This DataTemplate object can be used to specify an arbitrary layout and adorners for the buttons in the input prompt.

CopyC#
public static void Show(
    ControlTemplate template,
    object title,
    IEnumerable<object> buttonsContent,
    object message = null,
    InputMode inputMode = InputMode.Text,
    Style inputStyle = null,
    object checkBoxContent = null,
    bool isCheckBoxChecked = false,
    bool vibrate = false,
    HorizontalAlignment horizontalAlignment = HorizontalAlignment.Stretch,
    VerticalAlignment verticalAlignment = VerticalAlignment.Top,
    Action<InputPromptClosedEventArgs> closedHandler = null,
    Action<KeyEventArgs> keyDownHandler = null)

The last overload provides the most flexibility and is therefore most time consuming to use. Its first argument is a ControlTemplate. This means that you will have to define a completely new ControlTemplate for the RadInputPromptControl type in order to use it.

The Close method can be used to manually close the currently open input prompt. It has an argument providing an option to specify the pressed key index in order to initialize correctly the InputPromptClosedEventArgs.