Pivot allows you to easily move between pages in your app. This is very intuitive when it comes to touch screen and mobile apps.
Windows 10 Universal Apps have made implementing pivot a little less painful than it was in Windows 8.1.
No longer must you create a pivot app, a Universal App can implement one too.
So how do you do it?
Step 1:
Create a blank Windows 10 App in Visual C#.
Step 2: Open your MainPage.xaml.
From here go to the tool box (it should be on the left side of Visual Studio). You might have to look under "common XAML controls". Scroll through until you find "pivot". You can drag across onto your app.
Step 3: Fill it up
The header represents the name that will display along the top of your app. It defaults to "PivotItem 0".
If you wish to add more pages, simply add more pivot items using the code:
<pivotItem> </pivotItem>Each one of these will act as its own individual page.
Here is an example of some code in a pivot item.
I've set up two rows, added in an image of a cat, and added in a text block. The picture goes on the top row, the text goes below. Not very fancy, but it will get the job done. I've gone and coded something similar for the other pages, with a dog and a monkey. Here is the visual result of all this fun.
That is the core of it. Surprisingly easy to implement. Perhaps useful if you wanted to allow a user to move between a main page and say, settings or have an information app with different entries. Perhaps, various entries on different types of dogs, or spoon varieties. Whatever interests you the most.
I'll leave it at that for now, hopefully this has given you an idea on how to implement pivot in C#.
No comments:
Post a Comment