Help with Control Template

3 posts, 0 answers
  1. David
    David avatar
    15 posts
    Member since:
    Mar 2013

    Posted 21 Aug 2013 Link to this post

    I am using RadMessageBox with a custom Control Template.

    Here is my template:
    <ControlTemplate x:Key="StoreTemplate" TargetType="special:RadMessageBoxControl">
        <Border Padding="12" Background="{StaticResource PhoneChromeBrush}">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="*"/>
                </Grid.RowDefinitions>
                <ContentControl x:Name="PART_Title" HorizontalContentAlignment="Left" FontSize="{StaticResource PhoneFontSizeLarge}" FontFamily="{StaticResource PhoneFontFamilySemiBold}" Margin="{StaticResource PhoneMargin}" />
                <Grid Grid.Row="1">
                    <ContentControl HorizontalContentAlignment="Left"  VerticalContentAlignment="Top" FontSize="{StaticResource PhoneFontSizeNormal}" FontFamily="{StaticResource PhoneFontFamilyNormal}" x:Name="PART_Message"  Margin="12, 12, 12, 24">
                        <ContentControl.ContentTemplate>
                            <DataTemplate>
                                <TextBlock Text="{Binding}" TextWrapping="Wrap"  />
                            </DataTemplate>
                        </ContentControl.ContentTemplate>
                    </ContentControl>
                </Grid>
                <CheckBox x:Name="PART_CheckBox" Grid.Row="2" HorizontalAlignment="Left" VerticalAlignment="Bottom" />
                <ContentControl Grid.Row="3" x:Name="PART_ButtonsContainer" HorizontalContentAlignment="Stretch">
                    <ContentControl.ContentTemplate>
                        <DataTemplate>
                            <StackPanel x:Name="PART_ButtonsPanel" Orientation="Horizontal" HorizontalAlignment="Center"></StackPanel>
                        </DataTemplate>
                    </ContentControl.ContentTemplate>
                </ContentControl>
            </Grid>
        </Border>
    </ControlTemplate>

    I call RadMessageBox with the following code:
    var userResponse = await RadMessageBox.ShowAsync(msgTemplate, AppResources.TrialMsgTitle, new string[] { AppResources.UpgradeButtonText, AppResources.TrialButtonText, AppResources.LaterButtonText }, AppResources.TrialMsgMsg, null, false, false, HorizontalAlignment.Stretch, VerticalAlignment.Top);

    The message displays fine, however, the three buttons are stacked vertically on top of each other.

    Is there a way to get them lined up next to each other horizontally?

    Also, the text in the Buttons is aligned to the left. Any way to get it centered?




  2. David
    David avatar
    15 posts
    Member since:
    Mar 2013

    Posted 23 Aug 2013 Link to this post

    Here's a bit more information:

    If I only specify two buttons, they do line up Horizontally. The buttons are stretched so that each one is is about 1/2 the width of the screen, even if the button's Content label is one character wide.

    If I add a third button, they are arranged vertically, centered on the screen, and each button is only as wide as it needs to be to display the Content label.

    The attached files show these two scenerios.
  3. DevCraft banner
  4. Todor
    Admin
    Todor avatar
    778 posts

    Posted 23 Aug 2013 Link to this post

    Hi David,

    Thank you for writing.

    The buttons in RadMessageBox follow the design principles in Windows Phone. There are some values which are hardcoded and cannot be changed. The behavior that is intended is that if the buttons are two - they are in one line, if they are more - each button is on a different line. If for some reason, you need to have more than two buttons in one line, you can use RadWindow and add the buttons that you want in a completely custom way.

    If you have other questions, don't hesitate to write us back.
     
    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.
Back to Top