Reputation: 22947
I have several xaml pages in a WP7 MVVM project. I want to take these pages and combine them together into a pivot page.
All the tutorials show how to begin with a pivot page but i am looking for an easy method without too much re-factoring to turn my pages into a pivot page
I already have ViewModels for my pages so i am wondering how a new Pivot page interact with it
Thanks
Upvotes: 1
Views: 732
Reputation: 9478
If you're using something like Caliburn Micro it's as simple as adding your new pages' ViewModels to the main PageViewModels Items collection.
So in the MainPage.xaml
<controls:Pivot x:Name="Items" />
and in MainPageViewModel:
Items.Add(Page1ViewModel);
Items.Add(Page2ViewModel);
Items.Add(Page3ViewModel);
Upvotes: 0
Reputation: 1084
The way Ive done this in the past is to add a new pivot page to my solution. So, lets say you have 2 pages that you would like to add to a pivot page, you could add a new pivot page to your solution and then copy the content of each page into the pivot page into the appropriate section, such as:
<controls:PivotItem Header="item1">
YOUR PAGE1 CONTENT HERE
</controls:PivotItem>
<!--Pivot item two-->
<controls:PivotItem Header="item2">
YOUR PAGE2 CONTENT HERE
</controls:PivotItem>
Upvotes: 1
Reputation: 430
You can do this by adding a few lines in the xaml.
You'll need a reference to the silverlight toolkit (easy to obtain online).
<controls:Pivot Name="pivotControl">
<!--Pivot item one-->
<controls:PivotItem Header="Header1">
<!--Page 1 here-->
</controls:PivotItem>
<controls:PivotItem Header="Header2">
<!--Page 2 here-->
</controls:PivotItem>
</controls:Pivot>
Repeat as necessary.
I hope this answers your question.
Upvotes: 0