0

I have a large amount of content, about the size of a small book, over 10k words, I was thinking to make a book reader-like style, but Windows Phone SDK doesn't have such a control.

How can I handle this data?

error_null_pointer
  • 457
  • 1
  • 6
  • 21
Joe Lu
  • 2,240
  • 1
  • 15
  • 18
  • 1
    What exactly is "book reader-style"? Can you explain (maybe a picture) exactly what you would want it to look like? – steveg89 Dec 20 '13 at 15:22

1 Answers1

2

Is the material divided into sections or chapters? If so, how about this:

LongListSelector to hold chapters; this is your table of contents. Selecting chapter opens a new page.

Break the section materials into various "pages" of enough content to fill the phone screen. Dynamically create PivotItems to hold each of these pages. That way the user swipes side to side to change pages.

Provide appbar buttons to go forward and back a chapter, and a link to the table of contents.

Is that what you had in mind?

EDIT: Giving some sample code for dynamic pivot items.

You'll need to add a foreach loop, if statement, or other item to determine when/how many PivotItems to make. Also, include an if statement to skip this code if you've already loaded the page or you'll end up with duplicate PivotItems. I typically do this in the overriden OnNavigatedTo method.

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);

EDIT: One important thing to remember: You can't Collapse PivotItems. Their contents can be collapsed, but the item will still be present in the app (the user will swipe to a blank object). If you need to hide the item, you'll need to actually remove it from the Pivot control.

  • tks for the reply, chapters with listselector actually is not an option, the content doesn't actually have a chapter :) – Joe Lu Dec 20 '13 at 16:10
  • but the dynamically piovtitems sounds like a solution, do you have any quides for that? anyway, tks for the answers – Joe Lu Dec 20 '13 at 16:11
  • Am updating the reply with some sample code for adding dynamic pivot items. – Mark MacDonnell Dec 21 '13 at 01:07
  • @MarkMacDonnell Great approach, I have a situation suppose if my table of conents are like following than what approach you will suggest to implement in windows phone 8. http://stackoverflow.com/questions/23907020/dynamically-create-a-treeview-in-windows-phone-8-from-json-data – Ashish-BeJovial May 30 '14 at 09:15