Buttons Width

5 posts, 1 answers
  1. Romasz
    Romasz avatar
    8 posts
    Member since:
    Dec 2013

    Posted 01 Jan 2014 Link to this post

    Hello,

    I'm trying to use InputPrompt with three buttons in one line. I created own DataTemplate for this purpose, but it seems that buttons regards its content have minimum width - so that only two buttons can be placed horizontally. Is it possible to change buttons width so that there can be more buttons in one line?

    I've used such a code:

    <DataTemplate x:Key="ButtonsTemplate">
        <StackPanel x:Name="PART_ButtonsPanel" Orientation="Horizontal"/>
    </DataTemplate>
    And in code behind:

    DataTemplate buttonsTemplate = (DataTemplate)this.Resources["ButtonsTemplate"];
     
    InputPromptClosedEventArgs result = await RadInputPrompt.ShowAsync(buttonsTemplate: buttonsTemplate, title: "My Title", buttonsContent: new string[] { "OK", "Not OK", "Cancel" },
        message: "My message", isCheckBoxChecked: true, checkBoxContent: "Please check this checkbox", inputMode: InputMode.Text,
        vibrate: false, horizontalAlignment: System.Windows.HorizontalAlignment.Stretch, verticalAlignment: System.Windows.VerticalAlignment.Top);


  2. Todor
    Admin
    Todor avatar
    778 posts

    Posted 02 Jan 2014 Link to this post

    Hi Tomasz,

    Thank you for your question.

    By design, when the buttons in RadInputPrompt are 3 or more, each of them is displayed on a different line. Otherwise, the buttons are on one row. You can't change this behavior because it is not part of the style, but part of the code. If you need fully customized layout for your input prompt, you can use RadWindow and manually arrange all the content as desired.

    Regards,
    Todor
    Telerik
    Have a suggestion or face a problem - you can use the Ideas & Feedback portal to submit ideas, feedback and vote for them.
  3. DevCraft banner
  4. Romasz
    Romasz avatar
    8 posts
    Member since:
    Dec 2013

    Posted 02 Jan 2014 Link to this post

    Hello Todor,

    Thank you for the answer. As I'm finishing my project now I'll use standard InputPrompt with buttonsDatatemplate from RadWrapPanel - then I've two buttons in one line and third below. It will be sufficient for now, your idea to use RaWindow may be a good solution - I'll try it within next update.

    Then I have one more question - is it possible that keyboard won't show when InputPrompt is invoked, but only when the user taps TextBox?

    Regards,

    Tomasz

  5. Answer
    Todor
    Admin
    Todor avatar
    778 posts

    Posted 02 Jan 2014 Link to this post

    Hello Tomasz,

    The keyboard is automatically shown when the input prompt control takes the focus. In order to hide it you need to make sure that the focus returns to the page when it is taken from the input prompt. Add the following code the constructor of your page:
    this.LostFocus += this.MainPage_LostFocus;
    And add the following event handler:
    private void MainPage_LostFocus(object sender, RoutedEventArgs e)
    {
        if (e.OriginalSource is Telerik.Windows.Controls.InputPrompt.RadInputPromptControl)
        {
            this.Focus();
        }
    }

    I hope this helps.

    Regards,
    Todor
    Telerik
    Have a suggestion or face a problem - you can use the Ideas & Feedback portal to submit ideas, feedback and vote for them.
  6. Romasz
    Romasz avatar
    8 posts
    Member since:
    Dec 2013

    Posted 02 Jan 2014 Link to this post

    Hello Todor,

    yeah - this is an easy solution and good enough. Thank you.

    Regards,

     Tomasz

Back to Top
DevCraft banner