This is a migrated thread and some comments may be shown as answers.

Help with Control Template

2 Answers 64 Views
MessageBox
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
David
Top achievements
Rank 1
David asked on 21 Aug 2013, 03:56 PM
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 Answers, 1 is accepted

Sort by
0
David
Top achievements
Rank 1
answered on 23 Aug 2013, 10:37 AM
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.
0
Todor
Telerik team
answered on 23 Aug 2013, 11:21 AM
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.
Tags
MessageBox
Asked by
David
Top achievements
Rank 1
Answers by
David
Top achievements
Rank 1
Todor
Telerik team
Share this question
or