Question

In my project (windows Phone 8 C#/XAML .NET 4.5 Application) I'm using Windows Phone Toolkit.

While using CustomMessageBox, I've run into a problem when I use the CustomMessageBox for long text.

here is an example:

 CustomMessageBox box = new CustomMessageBox();
 box.content = "some really some really some really some really some really some really some really some really some really some really some really some really some really some really long text";
 box.Show();

And the text isn't wrapped or scrollable. So I tried Adding it into textblock:

CustomMessageBox box = new CustomMessageBox();
TextBlock txtblck = "some really some really some really some really some really some really some really some really some really some really some really some really some really some really long text";
txtblck.TextWrapping = TextWrapping.Wrap;
box.content = txtblck;
box.Show();

So finally, the text is wrapping as i need, but there is still another problem. How to make it scrollable - for example when you have a really long text - some long notice or legal agreement et cetera...

What should I do? I tried adding the textblock into ScrollViewer, but it does not work. I can scroll a bit, but it does not stay scrollable and when i stop trying to scroll down it returns to the starting position.

example:

 ScrollViewer viewer = new ScrollViewer();

 TextBlock txtInfo = new TextBlock();
 txtInfo.Text = "some long text here.....";
 txtInfo.TextWrapping = TextWrapping.Wrap;

 viewer.Content = txtInfo;

 CustomMessageBox Box = new CustomMessageBox();
 Box.Content = viewer;
 Box.Show();

How can i make the long text/content scrollable? Should I use another solution?

Was it helpful?

Solution

You need to define a fixed value for the height

ScrollViewer viewer = new ScrollViewer() { Height = 500 /* fixed Height */ };

TextBlock txtInfo = new TextBlock();
txtInfo.Text = @"some long text here.....";
txtInfo.TextWrapping = TextWrapping.Wrap;

viewer.Content = txtInfo;


CustomMessageBox Box = new CustomMessageBox();
Box.Content = viewer;
Box.Show();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top