【发布时间】:2013-12-21 09:23:45
【问题描述】:
我的内容量很大,大概一本小书的大小,10k多字,我想做一个书本阅读器的样式,但是Windows Phone SDK没有这样的控件。
我该如何处理这些数据?
【问题讨论】:
-
究竟什么是“读书风格”?你能解释一下(也许是一张图片)你希望它是什么样子吗?
标签: xaml windows-phone-8
我的内容量很大,大概一本小书的大小,10k多字,我想做一个书本阅读器的样式,但是Windows Phone SDK没有这样的控件。
我该如何处理这些数据?
【问题讨论】:
标签: xaml windows-phone-8
材料是否分为部分或章节?如果是这样,怎么样:
LongListSelector 保存章节;这是您的目录。选择章节会打开一个新页面。
将部分材料分解成各种“页面”,内容足以填满手机屏幕。动态创建 PivotItems 来保存这些页面中的每一个。这样用户就可以左右滑动来切换页面。
提供用于前进和后退章节的应用栏按钮,以及指向目录的链接。
这就是你的想法吗?
编辑:为动态数据透视项目提供一些示例代码。
您需要添加一个 foreach 循环、if 语句或其他项目来确定何时/多少 PivotItems。此外,如果您已经加载了页面,请包含一个 if 语句以跳过此代码,否则您将得到重复的 PivotItems。我通常在重写的 OnNavigatedTo 方法中执行此操作。
PivotItem pivotItem = new PivotItem()
{
Header = "Header"
// Add the rest of your PivotItem specific values here
};
// You'll need to add the grid item, and contents, that will reside in the PivotItem
Grid grid = new Grid();
grid.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto });
grid.RowDefinitions.Add(new RowDefinition());
TextBlock textBlock = new TextBlock();
textBlock.Text = "Text";
/* Don't apply styling in code behind. It won't work. Make the style item in XAML and set it via Control.Style for the given item */
textBlock.Style = PivotItemTitleStyle;
// Make sure you add the various items to the grid
grid.Children.Add(textBlock);
// Add the grid to the PivotItem
pivotItem.Content = grid;
/* And the PivotItem to the Pivot control. Do this for each PivotItem you need via a foreach loop, etc. */
MainPivot.Items.Add(pivotItem);
编辑:要记住的一件重要事情:您不能折叠 PivotItems。它们的内容可以折叠,但该项目仍会出现在应用程序中(用户将滑动到空白对象)。如果您需要隐藏该项目,则需要将其从 Pivot 控件中实际移除。
【讨论】: