Windows store app prism startup or first launching page change
In App.xaml.cs file you can see the below method which contains navigation service code that is responsible to set start up page.
If you have MainPage.xaml page in Views folder the below code is used to set as start up page.
protected override Task OnLaunchApplication(LaunchActivatedEventArgs args)
{
NavigationService.Navigate("Main", null);
return Task.FromResult<object>(null);
}
\
If you have SecondPage.xaml page in Views folder the below code is used to set it as start up page.
If you have MainPage.xaml page in Views folder the below code is used to set as start up page.
protected override Task OnLaunchApplication(LaunchActivatedEventArgs args)
{
NavigationService.Navigate("Main", null);
return Task.FromResult<object>(null);
}
\
If you have SecondPage.xaml page in Views folder the below code is used to set it as start up page.
protected override Task OnLaunchApplication(LaunchActivatedEventArgs args)
{
NavigationService.Navigate("Second", null);
return Task.FromResult<object>(null);
}
Windows Store app prism Navigation from one page or view to other
In prism to navigate from one page to other Navigation Service is used.
Every page you create in prism should be suffixed by Page but it is not considered as page name.
For example: Under view folder create a view - Right click on Views folder - Add New Item - Page View(Prism) - SecondPage
Second is the view name and Page is used as Suffix to recognize it as a view Page.
Windows store app xaml c# Installing prism template and Creating first app
Prism is from Microsoft Patterns and Practises.
It is used to create WPF, Silverlight and windows store apps.
It provides services like loosely coupled MVVM pattern, Navigation and app life cycle management, Flyout services, validations.
Prism for Windows runtime templates for 8/8.1 are now available as a Nuget Package.
Install it to start creating windows store prism app.
Installation steps:
Click on tools from the top menu and then select extensions and updates.
Create a new project in your visual studio.
And Use prism App Template to create prism app.
Prism app Solution Explorer
It is used to create WPF, Silverlight and windows store apps.
It provides services like loosely coupled MVVM pattern, Navigation and app life cycle management, Flyout services, validations.
Prism for Windows runtime templates for 8/8.1 are now available as a Nuget Package.
Install it to start creating windows store prism app.
Installation steps:
Click on tools from the top menu and then select extensions and updates.
Search for prism windows runtime template from online.
Click on downlad and then install.
Winrt Prism templates are available for 8 and 8.1.
Download and install it to start creating windows runtime prism app using prism template.
And Use prism App Template to create prism app.
Prism app Solution Explorer
windows store app prism xaml code for orientation landscape portrait view handling using visual state manager to change properties of controls in runtime
xaml code for handling landscape and orientations of windows store app developed using prism
Note: Write the VisualStateManger Groups xaml code at the starting inside root grid in your page.
Needs no C# code for handling this orientations.
The following xaml code makes change in property values when orientation of the app changed from landscape to portrait view and it will undo the changes when the app comes back to landscape mode.
1. grid view collapse and visible
1. grid view collapse and visible
2. List View font family thickness and vertical alignment
3. Textblock fontsize
4. Grid Row no, Column no, ColumnSpan
5. Button width and height
5. Button width and height
XAML Code
<Grid>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="ApplicationViewStates">
<VisualState x:Name="DefaultLayout"/>
<VisualState x:Name="PortraitLayout">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="portraitEventViewModelsGridView">
<DiscreteObjectKeyFrame KeyTime="0">
<DiscreteObjectKeyFrame.Value>
<Visibility>Visible</Visibility>
</DiscreteObjectKeyFrame.Value>
</DiscreteObjectKeyFrame>
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="landscapeEventViewModelsGridView">
<DiscreteObjectKeyFrame KeyTime="0">
<DiscreteObjectKeyFrame.Value>
<Visibility>Collapsed</Visibility>
</DiscreteObjectKeyFrame.Value>
</DiscreteObjectKeyFrame>
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(Control.FontFamily)" Storyboard.TargetName="ListView1">
<DiscreteObjectKeyFrame KeyTime="0">
<DiscreteObjectKeyFrame.Value>
<FontFamily>Global User Interface</FontFamily>
</DiscreteObjectKeyFrame.Value>
</DiscreteObjectKeyFrame>
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(Control.BorderThickness)" Storyboard.TargetName="ListView1">
<DiscreteObjectKeyFrame KeyTime="0">
<DiscreteObjectKeyFrame.Value>
<Thickness>50,200,50,0</Thickness>
</DiscreteObjectKeyFrame.Value>
</DiscreteObjectKeyFrame>
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.VerticalAlignment)" Storyboard.TargetName="ListView1">
<DiscreteObjectKeyFrame KeyTime="0">
<DiscreteObjectKeyFrame.Value>
<VerticalAlignment>Top</VerticalAlignment>
</DiscreteObjectKeyFrame.Value>
</DiscreteObjectKeyFrame>
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="TextBlock1" Storyboard.TargetProperty="(TextBlock.FontSize)">
<DiscreteObjectKeyFrame Value="20" KeyTime="0">
</DiscreteObjectKeyFrame>
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="Grid1"
Storyboard.TargetProperty="(Grid.Column)">
<DiscreteObjectKeyFrame KeyTime="0" Value="1"/>
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="Grid1"
Storyboard.TargetProperty="(Grid.Row)">
<DiscreteObjectKeyFrame KeyTime="0" Value="1"/>
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="Grid1"
Storyboard.TargetProperty="(Grid.ColumnSpan)">
<DiscreteObjectKeyFrame KeyTime="0" Value="2"/>
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="Button1" Storyboard.TargetProperty="(Button.Width)">
<DiscreteObjectKeyFrame Value="225" KeyTime="0">
</DiscreteObjectKeyFrame>
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="Button1" Storyboard.TargetProperty="(Button.Height)">
<DiscreteObjectKeyFrame Value="56" KeyTime="0">
</DiscreteObjectKeyFrame>
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="Button1" Storyboard.TargetProperty="(Button.Width)">
<DiscreteObjectKeyFrame Value="225" KeyTime="0">
</DiscreteObjectKeyFrame>
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="Button1" Storyboard.TargetProperty="(Button.Height)">
<DiscreteObjectKeyFrame Value="56" KeyTime="0">
</DiscreteObjectKeyFrame>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
</Grid>




