Created
November 22, 2015 03:18
-
-
Save pierre3/fda4dc99d118f443d2b3 to your computer and use it in GitHub Desktop.
[UWP][Prism] NavigationServiceの対象FrameをMainPageのSpritViewに設定するやつ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Prism.Unity.Windows; | |
using RssReaderApp.Views; | |
using System.Threading.Tasks; | |
using Windows.ApplicationModel.Activation; | |
using Windows.UI.Xaml; | |
using Windows.UI.Xaml.Controls; | |
namespace RssReaderApp | |
{ | |
/// <summary> | |
/// 既定の Application クラスを補完するアプリケーション固有の動作を提供します。 | |
/// </summary> | |
sealed partial class App : PrismUnityApplication | |
{ | |
private Frame _rootFrame; | |
public App() | |
{ | |
InitializeComponent(); | |
} | |
protected override UIElement CreateShell(Frame rootFrame) | |
{ | |
_rootFrame = rootFrame; | |
return base.CreateShell(rootFrame); | |
} | |
protected override Task OnLaunchApplicationAsync(LaunchActivatedEventArgs args) | |
{ | |
var mainPage = Window.Current.Content as MainPage; | |
if (mainPage == null) | |
{ | |
mainPage = new MainPage(); | |
mainPage.frameContainer.Content = _rootFrame; | |
Window.Current.Content = mainPage; | |
} | |
if (_rootFrame.Content == null) | |
{ | |
NavigationService.Navigate("Init", null); | |
} | |
return Task.CompletedTask; | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Page | |
x:Class="RssReaderApp.Views.MainPage" | |
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |
xmlns:local="using:RssReaderApp" | |
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | |
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | |
xmlns:mvvm="using:Prism.Windows.Mvvm" | |
mvvm:ViewModelLocator.AutoWireViewModel="True" | |
mc:Ignorable="d"> | |
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> | |
<Grid.RowDefinitions> | |
<RowDefinition Height="Auto"/> | |
<RowDefinition/> | |
</Grid.RowDefinitions> | |
<StackPanel Orientation="Horizontal"> | |
<ToggleButton Content="" | |
FontFamily="{StaticResource SymbolThemeFontFamily}" | |
IsChecked="{Binding IsPainOpen,ElementName=SplitView}"/> | |
<TextBlock Text="RSS リーダー" Style="{StaticResource TitleTextBlockStyle}"/> | |
</StackPanel> | |
<SplitView Grid.Row="1" x:Name="SplitView"> | |
<SplitView.Pane> | |
<!-- Menu --> | |
<ListView ItemsSource="{x:Bind ViewModel.Feeds}" ></ListView> | |
</SplitView.Pane> | |
<ContentControl x:Name="frameContainer" x:FieldModifier="public" > | |
<!-- ここにFrameが入る --> | |
</ContentControl> | |
</SplitView> | |
</Grid> | |
</Page> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment