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

Text align problem with RADMessageBox.

1 Answer 188 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.
Saurav
Top achievements
Rank 1
Saurav asked on 30 Aug 2013, 08:56 AM
Hello, I am trying to create a 3 button messageBox using RADMessageBox in my Windows Phone project. When I use two buttons, the button content or label is automatically centre aligned. However, when I give three buttons than text is left aligned. How do I align text to centre?

I have attached an example of what I get and what is expected.

Expected

What I get

One method I know is to make a custom control template but is there another way already specified in RADMessageBox which can let me do this?

1 Answer, 1 is accepted

Sort by
0
Kiril Stanoev
Telerik team
answered on 02 Sep 2013, 11:26 AM
Hello Saurav,

Thank you for contacting us. Indeed, this scenario can be achieved through the usage of a custom ControlTemplate.

<UserControl.Resources>
    <ControlTemplate x:Key="ImageTemplate" TargetType="telerikMessageBox: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}" />
                <StackPanel Grid.Row="1" Orientation="Horizontal">
                    <Image Source="idjits.jpg" Margin="12, 12, 0, 24" />
                    <ContentControl HorizontalContentAlignment="Left" VerticalContentAlignment="Top"
                            x:Name="PART_Message" Margin="12, 12, 12, 24" />
                </StackPanel>
                <CheckBox x:Name="PART_CheckBox" Grid.Row="2" HorizontalAlignment="Left" VerticalAlignment="Bottom" />
                <ContentControl Grid.Row="3" x:Name="PART_ButtonsContainer" HorizontalContentAlignment="Stretch"
                        HorizontalAlignment="Stretch" Margin="12 0" Width="440">
                    <ContentControl.ContentTemplate>
                        <DataTemplate>
                            <StackPanel x:Name="PART_ButtonsPanel" Loaded="PART_ButtonsPanel_Loaded" />
                        </DataTemplate>
                    </ContentControl.ContentTemplate>
                </ContentControl>
            </Grid>
        </Border>
    </ControlTemplate>
</UserControl.Resources>

public Playground()
{
    InitializeComponent();
    ControlTemplate imageTemplate = (ControlTemplate)this.Resources["ImageTemplate"];
    RadMessageBox.Show(imageTemplate, "Title", new string[] { "yes", "no", "maybe" });
}
 
private void PART_ButtonsPanel_Loaded(object sender, System.Windows.RoutedEventArgs e)
{
    var panel = sender as StackPanel;
    foreach (var item in panel.Children)
    {
        Button button = (Button)item;
        button.Width = double.NaN;
        button.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Stretch;
    }
}

Let me know how it goes. 

Regards,
Kiril Stanoev
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINDOWS PHONE 7.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
MessageBox
Asked by
Saurav
Top achievements
Rank 1
Answers by
Kiril Stanoev
Telerik team
Share this question
or