MessageBox with scrollable content?

3 posts, 1 answers
  1. Mirko
    Mirko avatar
    17 posts
    Member since:
    Jul 2013

    Posted 16 Oct 2013 Link to this post

    Hi,
    I've got just a simple question. I'd like to display MessageBox with rather lot of text that does not fit to the whole screen. Right now the RadMessageBox is not scrollable. How to achieve MessageBox with scrollable content and three buttons at the bottom?
    Thanks.
  2. Answer
    Kiril Stanoev
    Admin
    Kiril Stanoev avatar
    1511 posts

    Posted 17 Oct 2013 Link to this post

    Hi Mirko,

    Thank you for contacting us. To achieve this scenario you'll have to use a RadMessageBox with a custom ControlTemplate.

    xmlns:telerikMessageBox="clr-namespace:Telerik.Windows.Controls.MessageBox;assembly=Telerik.Windows.Controls.Primitives"

    <phone:PhoneApplicationPage.Resources>
        <ControlTemplate x:Key="MessageTemplate" TargetType="telerikMessageBox:RadMessageBoxControl">
            <Border Padding="12" Background="{StaticResource PhoneChromeBrush}">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="*" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                    </Grid.RowDefinitions>
                    <ContentControl x:Name="PART_Title" HorizontalContentAlignment="Left"
                            FontSize="{StaticResource PhoneFontSizeLarge}"
                            FontFamily="{StaticResource PhoneFontFamilySemiBold}" Margin="{StaticResource PhoneMargin}" />
                    <ScrollViewer Grid.Row="1">
                        <ContentControl x:Name="PART_Message" Margin="12, 12, 12, 24" HorizontalContentAlignment="Left"
                                VerticalContentAlignment="Top" />
                    </ScrollViewer>
                    <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"></StackPanel>
                            </DataTemplate>
                        </ContentControl.ContentTemplate>
                    </ContentControl>
                </Grid>
            </Border>
        </ControlTemplate>
    </phone:PhoneApplicationPage.Resources>
    <!--LayoutRoot is the root grid where all page content is placed-->
    <Grid x:Name="LayoutRoot" Background="Transparent">
        <Button Content="Show Message" Tap="Button_Tap" VerticalAlignment="Center" HorizontalAlignment="Center" />
    </Grid>

    public partial class ID747643 : PhoneApplicationPage
    {
        private ControlTemplate imageTemplate;
        public ID747643()
        {
            InitializeComponent();
            this.imageTemplate = (ControlTemplate)this.Resources["MessageTemplate"];
        }
     
        private void Button_Tap(object sender, System.Windows.Input.GestureEventArgs e)
        {
            RadMessageBox.Show(this.imageTemplate, "Title", new string[] { "yes", "no" }, this.longMessage);
        }
     
        private string longMessage = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc vel mollis ipsum, in mattis odio. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Vivamus vehicula vulputate nunc, dictum feugiat orci varius eget. Quisque mollis malesuada fermentum. Cras aliquam mauris quam, in pellentesque risus sodales sit amet. Morbi lacinia turpis non dictum malesuada. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Mauris eleifend euismod facilisis. Aliquam semper mi sapien, scelerisque sollicitudin lacus tincidunt et. Fusce posuere tincidunt urna at commodo. Duis et aliquet massa. Aenean et urna et dolor ultricies ultrices nec fermentum lacus. Curabitur ut nisl volutpat, varius felis non, aliquet magna. Curabitur vehicula at nibh et eleifend. Vestibulum at lectus nisi. Curabitur ut aliquet velit, vitae ornare neque. Integer tincidunt laoreet nisl, vel congue nulla lobortis a. Donec libero lacus, suscipit quis scelerisque nec, euismod id libero. Donec feugiat turpis a est elementum, ut iaculis quam porttitor. Cras ornare tortor eu porttitor placerat. Donec commodo convallis quam eu rhoncus. Etiam a consectetur justo. Aliquam quis elit diam. Donec malesuada magna sem, eget iaculis lectus posuere sit amet. Proin vehicula bibendum odio id rhoncus. Fusce pulvinar id leo lobortis placerat. Proin nibh mauris, eleifend id ornare ac, tristique ac turpis. Fusce turpis dui, ultricies sit amet aliquet eu, sodales sed nulla. Nam nec diam ac massa mattis venenatis id in neque. Praesent id dui nisl. Maecenas quis lectus id nibh interdum faucibus.";
    }
     
    The result from the code above would be something similar to this:

    Unable to display content. Adobe Flash is required.

    Give it a try and let us know how it works.

    Regards,
    Kiril Stanoev
    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. Mirko
    Mirko avatar
    17 posts
    Member since:
    Jul 2013

    Posted 18 Oct 2013 Link to this post

    Thanks, it works just fine!
Back to Top