【问题标题】:What's the best way to display a large amount content in Windows Phone 8 [closed]在 Windows Phone 8 中显示大量内容的最佳方式是什么 [关闭]
【发布时间】:2013-12-21 09:23:45
【问题描述】:

我的内容量很大,大概一本小书的大小,10k多字,我想做一个书本阅读器的样式,但是Windows Phone SDK没有这样的控件。

我该如何处理这些数据?

【问题讨论】:

  • 究竟什么是“读书风格”?你能解释一下(也许是一张图片)你希望它是什么样子吗?

标签: xaml windows-phone-8


【解决方案1】:

材料是否分为部分或章节?如果是这样,怎么样:

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 控件中实际移除。

【讨论】:

  • tks 回复,带有 listselector 的章节实际上不是一个选项,内容实际上没有章节:)
  • 但动态 piovtitems 听起来像是一个解决方案,您对此有什么要求吗?无论如何,谢谢答案
  • 我正在使用一些示例代码更新回复以添加动态数据透视项目。
  • @MarkMacDonnell 很好的方法,我有一种情况,假设我的内容表与您建议在 windows phone 8 中实施的方法相比,我的情况类似。stackoverflow.com/questions/23907020/…
猜你喜欢
  • 1970-01-01
  • 2015-08-12
  • 1970-01-01
  • 2013-12-14
  • 1970-01-01
  • 1970-01-01
  • 2014-02-12
  • 2012-06-13
  • 1970-01-01
相关资源
最近更新 更多