我有一个书籍应用程序,我正在使用FlipView
控件在用户当前正在阅读的书中任何选定章节的页面之间翻转。
我正在FlipView
使用以下代码动态创建页面并将它们作为项目添加到控件中:
private void CreateNewFlipPage(RichTextBlockOverflow columnContent, int page)
{
var fvItem = new FlipViewItem();
var grid = GetOverflowGrid(); // Pre-formatted grid with 4 columns (index 0, 2, 4, and 6) and three 30 pixel spacer columns in between (index 1, 3, and 5)
var overFlow1 = new RichTextBlockOverflow();
var overFlow2 = new RichTextBlockOverflow();
var overFlow3 = new RichTextBlockOverflow();
var overFlow4 = new RichTextBlockOverflow();
var pageText = new TextBlock
{
VerticalAlignment = Windows.UI.Xaml.VerticalAlignment.Bottom,
Opacity = 0.5,
FontSize = 18.667,
Margin = new Thickness(40, 0, 0, 0),
Foreground = Application.Current.Resources["ApplicationPageTextOppositeBackgroundThemeBrush"] as SolidColorBrush,
FontFamily = new FontFamily("Global User Interface"),
Text = "Page " + page
};
overFlow4.Margin = new Thickness(0, 0, 0, 40);
Grid.SetColumn(overFlow1, 0);
Grid.SetColumn(overFlow2, 2);
Grid.SetColumn(overFlow3, 4);
Grid.SetColumn(overFlow4, 6);
Grid.SetColumn(pageText, 6);
grid.Children.Add(overFlow1);
grid.Children.Add(overFlow2);
grid.Children.Add(overFlow3);
grid.Children.Add(overFlow4);
grid.Children.Add(pageText);
fvItem.Content = grid;
FlipView.Items.Add(fvItem);
overFlow1.OverflowContentTarget = columnContent;
overFlow2.OverflowContentTarget = overFlow1;
overFlow3.OverflowContentTarget = overFlow2;
overFlow4.OverflowContentTarget = overFlow3;
overFlow1.Measure(new Size(grid.ColumnDefinitions[0].ActualWidth, grid.ActualHeight));
overFlow2.Measure(new Size(grid.ColumnDefinitions[0].ActualWidth, grid.ActualHeight));
overFlow3.Measure(new Size(grid.ColumnDefinitions[0].ActualWidth, grid.ActualHeight));
overFlow4.Measure(new Size(grid.ColumnDefinitions[0].ActualWidth, grid.ActualHeight));
grid.UpdateLayout();
if (overFlow4.HasOverflowContent)
{
CreateNewFlipPage(overFlow4, page++);
}
}
一旦 UI 更新,我在我的 Initial UI 方法中调用此代码:
...
if (column4Content.HasOverflowContent)
{
CreateNewFlipPage(column4Content, 2); // column4Content is a RTBO object
}
...
如果我不调用最后一部分,我会得到第一个完整页面,而没有其他任何内容。
如果我确实调用了最后一部分,我会在第一页上获得前 3 列,并将一个项目添加到FlipView
,但第二页上没有显示任何文本,并且第 4 列消失了
我没有做什么来显示所有 RTBO 对象?