Is it possible to have the TextFlow automatically scroll as the lines exceed the viewable area?
I tried to figure out ScrollViewer without much luck.
Thanks
Is it possible to have the TextFlow automatically scroll as the lines exceed the viewable area?
I tried to figure out ScrollViewer without much luck.
Thanks
What was the problem you hit with ScrollViewer, code to look at?
There isn’t any example code to follow for the ScrollViewer.
Basically I stuck a TextFlow inside a ScrollViewer during testing, then called LineDown and LineUp with no changes.
Thanks
Try this, it works well for us
static private Window mainWindow;
static public Window CreateWindow() {
// Create a window object and set its size to the
// size of the display.
mainWindow = new Window {
Height = 272,
Width = 480
};
// Create a scrollviewer
var scrollViewer = new ScrollViewer {
Background = new SolidColorBrush(Colors.Gray),
// scroll line by line with 10 pixels per line
ScrollingStyle = ScrollingStyle.LineByLine,
LineWidth = 10,
LineHeight = 10
};
// Create a canvas and add ellipse shapes
var canvas = new Canvas();
var font = Resources.GetFont(Resources.FontResources.droid_reg11);
for (var x = 0; x <= 20; ++x) {
var textFlow = new TextFlow();
textFlow.TextRuns.Add("Line " + x, font, GHIElectronics.TinyCLR.UI.Media.Color.FromRgb(0xFF, 0xFF, 0xFF));
textFlow.TextRuns.Add(TextRun.EndOfLine);
canvas.Children.Add(textFlow);
Canvas.SetLeft(textFlow, 30);
Canvas.SetTop(textFlow, x * 30);
}
//we need to set the size of a canvas explicitly
//because it doesn´t calculate the desired size from its content
canvas.Width = 20 * 30 + 10 * 2;
canvas.Height = 20 * 30 + 10 * 2;
scrollViewer.Child = canvas;
// Add the scroll viewer to the window.
mainWindow.Child = scrollViewer;
// Set the window visibility to visible.
mainWindow.Visibility = Visibility.Visible;
scrollViewer.TouchUp += ScrollViewer_TouchUp;
return mainWindow;
}
private static void ScrollViewer_TouchUp(object sender, GHIElectronics.TinyCLR.UI.Input.TouchEventArgs e) {
var s = (ScrollViewer)sender;
s.LineDown();
}
ScrollingStyle enums are wrong.
Thanks, we will check.