Skip to content

Commit

Permalink
Resolves Windows-XAML#447, and fixes BackButtonBehavior
Browse files Browse the repository at this point in the history
  • Loading branch information
jerrynixon committed Jan 7, 2016
1 parent 424bad1 commit c831433
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 57 deletions.
82 changes: 41 additions & 41 deletions Samples/PageHeaderSample/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,46 +6,46 @@

namespace PageHeaderSample
{
/// Documentation on APIs used in this page:
/// https://github.com/Windows-XAML/Template10/wiki

sealed partial class App : Template10.Common.BootStrapper
{
ISettingsService _settings;

public App()
{
InitializeComponent();
SplashFactory = (e) => new Views.Splash(e);

#region App settings

_settings = SettingsService.Instance;
RequestedTheme = _settings.AppTheme;
CacheMaxDuration = _settings.CacheMaxDuration;
ShowShellBackButton = _settings.UseShellBackButton;

#endregion
}

// runs even if restored from state
public override async Task OnInitializeAsync(IActivatedEventArgs args)
{
// setup hamburger shell
var nav = NavigationServiceFactory(BackButton.Attach, ExistingContent.Include);
Window.Current.Content = new Views.Shell(nav);
await Task.Yield();
}

// runs only when not restored from state
public override async Task OnStartAsync(StartKind startKind, IActivatedEventArgs args)
{
// perform long-running load
await Task.Delay(0);

// navigate to first page
NavigationService.Navigate(typeof(Views.MainPage));
}
}
/// Documentation on APIs used in this page:
/// https://github.com/Windows-XAML/Template10/wiki

sealed partial class App : Template10.Common.BootStrapper
{
ISettingsService _settings;

public App()
{
InitializeComponent();
SplashFactory = (e) => new Views.Splash(e);

#region App settings

_settings = SettingsService.Instance;
RequestedTheme = _settings.AppTheme;
CacheMaxDuration = _settings.CacheMaxDuration;
ShowShellBackButton = _settings.UseShellBackButton;

#endregion
}

// runs even if restored from state
public override async Task OnInitializeAsync(IActivatedEventArgs args)
{
// setup hamburger shell
var nav = NavigationServiceFactory(BackButton.Attach, ExistingContent.Include);
Window.Current.Content = new Views.Shell(nav);
await Task.Yield();
}

// runs only when not restored from state
public override async Task OnStartAsync(StartKind startKind, IActivatedEventArgs args)
{
// perform long-running load
await Task.Delay(0);

// navigate to first page
NavigationService.Navigate(typeof(Views.MainPage));
}
}
}

2 changes: 1 addition & 1 deletion Samples/PageHeaderSample/Views/Shell.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public sealed partial class Shell : Page, INotifyPropertyChanged
public static Shell Instance { get; set; }
public static HamburgerMenu HamburgerMenu { get { return Instance.MyHamburgerMenu; } }

public Shell(NavigationService navigationService)
public Shell(INavigationService navigationService)
{
Instance = this;
InitializeComponent();
Expand Down
Binary file not shown.
Binary file not shown.
6 changes: 2 additions & 4 deletions Template10 (Library)/Behaviors/BackButtonBehavior.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public class BackButtonBehavior : DependencyObject, IBehavior

public void Attach(DependencyObject associatedObject)
{
AssociatedObject = associatedObject;
_dispatcher = WindowWrapper.Current().Dispatcher;
BootStrapper.BackRequested += BootStrapper_BackRequested;
}
Expand All @@ -25,10 +26,7 @@ public void Detach()
private void BootStrapper_BackRequested(object sender, HandledEventArgs e)
{
e.Handled = Handled;
foreach (IAction item in Actions)
{
_dispatcher.Dispatch(() => item.Execute(sender, null));
}
Interaction.ExecuteActions(AssociatedObject, Actions, null);
}

public bool Handled
Expand Down
11 changes: 0 additions & 11 deletions Template10.sln
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ Global
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{9A82F6E0-3AC8-440C-AA37-714920D8FB85}.Debug|Any CPU.ActiveCfg = Debug|x86
{9A82F6E0-3AC8-440C-AA37-714920D8FB85}.Debug|Any CPU.Build.0 = Debug|x86
{9A82F6E0-3AC8-440C-AA37-714920D8FB85}.Debug|ARM.ActiveCfg = Debug|ARM
{9A82F6E0-3AC8-440C-AA37-714920D8FB85}.Debug|ARM.Build.0 = Debug|ARM
{9A82F6E0-3AC8-440C-AA37-714920D8FB85}.Debug|ARM.Deploy.0 = Debug|ARM
Expand All @@ -88,7 +87,6 @@ Global
{9A82F6E0-3AC8-440C-AA37-714920D8FB85}.Release|x86.Build.0 = Release|x86
{9A82F6E0-3AC8-440C-AA37-714920D8FB85}.Release|x86.Deploy.0 = Release|x86
{AF358EF5-8E5F-495D-B9E4-7FF123089AAA}.Debug|Any CPU.ActiveCfg = Debug|x86
{AF358EF5-8E5F-495D-B9E4-7FF123089AAA}.Debug|Any CPU.Build.0 = Debug|x86
{AF358EF5-8E5F-495D-B9E4-7FF123089AAA}.Debug|ARM.ActiveCfg = Debug|ARM
{AF358EF5-8E5F-495D-B9E4-7FF123089AAA}.Debug|ARM.Build.0 = Debug|ARM
{AF358EF5-8E5F-495D-B9E4-7FF123089AAA}.Debug|ARM.Deploy.0 = Debug|ARM
Expand All @@ -108,7 +106,6 @@ Global
{AF358EF5-8E5F-495D-B9E4-7FF123089AAA}.Release|x86.Build.0 = Release|x86
{AF358EF5-8E5F-495D-B9E4-7FF123089AAA}.Release|x86.Deploy.0 = Release|x86
{2BB9DA4B-F926-4523-9AE9-D670A9181317}.Debug|Any CPU.ActiveCfg = Debug|x86
{2BB9DA4B-F926-4523-9AE9-D670A9181317}.Debug|Any CPU.Build.0 = Debug|x86
{2BB9DA4B-F926-4523-9AE9-D670A9181317}.Debug|ARM.ActiveCfg = Debug|ARM
{2BB9DA4B-F926-4523-9AE9-D670A9181317}.Debug|ARM.Build.0 = Debug|ARM
{2BB9DA4B-F926-4523-9AE9-D670A9181317}.Debug|ARM.Deploy.0 = Debug|ARM
Expand Down Expand Up @@ -145,7 +142,6 @@ Global
{AC3E4F10-6615-4E16-BB0F-104760C92B95}.Release|x86.ActiveCfg = Release|x86
{AC3E4F10-6615-4E16-BB0F-104760C92B95}.Release|x86.Build.0 = Release|x86
{8C139B94-9B85-4CE6-ADCD-7E9365F45263}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8C139B94-9B85-4CE6-ADCD-7E9365F45263}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8C139B94-9B85-4CE6-ADCD-7E9365F45263}.Debug|ARM.ActiveCfg = Debug|ARM
{8C139B94-9B85-4CE6-ADCD-7E9365F45263}.Debug|ARM.Build.0 = Debug|ARM
{8C139B94-9B85-4CE6-ADCD-7E9365F45263}.Debug|x64.ActiveCfg = Debug|x64
Expand All @@ -160,7 +156,6 @@ Global
{8C139B94-9B85-4CE6-ADCD-7E9365F45263}.Release|x86.ActiveCfg = Release|x86
{8C139B94-9B85-4CE6-ADCD-7E9365F45263}.Release|x86.Build.0 = Release|x86
{4BAA93EC-B25A-4A7D-953D-0F4C07390078}.Debug|Any CPU.ActiveCfg = Debug|x86
{4BAA93EC-B25A-4A7D-953D-0F4C07390078}.Debug|Any CPU.Build.0 = Debug|x86
{4BAA93EC-B25A-4A7D-953D-0F4C07390078}.Debug|ARM.ActiveCfg = Debug|ARM
{4BAA93EC-B25A-4A7D-953D-0F4C07390078}.Debug|ARM.Build.0 = Debug|ARM
{4BAA93EC-B25A-4A7D-953D-0F4C07390078}.Debug|ARM.Deploy.0 = Debug|ARM
Expand All @@ -179,7 +174,6 @@ Global
{4BAA93EC-B25A-4A7D-953D-0F4C07390078}.Release|x86.Build.0 = Release|x86
{4BAA93EC-B25A-4A7D-953D-0F4C07390078}.Release|x86.Deploy.0 = Release|x86
{C27B1DB1-93BD-4070-9B6B-FEBD28B5CAB7}.Debug|Any CPU.ActiveCfg = Debug|x86
{C27B1DB1-93BD-4070-9B6B-FEBD28B5CAB7}.Debug|Any CPU.Build.0 = Debug|x86
{C27B1DB1-93BD-4070-9B6B-FEBD28B5CAB7}.Debug|ARM.ActiveCfg = Debug|ARM
{C27B1DB1-93BD-4070-9B6B-FEBD28B5CAB7}.Debug|ARM.Build.0 = Debug|ARM
{C27B1DB1-93BD-4070-9B6B-FEBD28B5CAB7}.Debug|ARM.Deploy.0 = Debug|ARM
Expand All @@ -198,7 +192,6 @@ Global
{C27B1DB1-93BD-4070-9B6B-FEBD28B5CAB7}.Release|x86.Build.0 = Release|x86
{C27B1DB1-93BD-4070-9B6B-FEBD28B5CAB7}.Release|x86.Deploy.0 = Release|x86
{0CE3C531-CD61-4AF9-A7D4-7EB93EA46A9F}.Debug|Any CPU.ActiveCfg = Debug|x86
{0CE3C531-CD61-4AF9-A7D4-7EB93EA46A9F}.Debug|Any CPU.Build.0 = Debug|x86
{0CE3C531-CD61-4AF9-A7D4-7EB93EA46A9F}.Debug|ARM.ActiveCfg = Debug|ARM
{0CE3C531-CD61-4AF9-A7D4-7EB93EA46A9F}.Debug|ARM.Build.0 = Debug|ARM
{0CE3C531-CD61-4AF9-A7D4-7EB93EA46A9F}.Debug|ARM.Deploy.0 = Debug|ARM
Expand All @@ -217,7 +210,6 @@ Global
{0CE3C531-CD61-4AF9-A7D4-7EB93EA46A9F}.Release|x86.Build.0 = Release|x86
{0CE3C531-CD61-4AF9-A7D4-7EB93EA46A9F}.Release|x86.Deploy.0 = Release|x86
{BE334D79-1D64-4638-B547-75400AA9A58B}.Debug|Any CPU.ActiveCfg = Debug|x86
{BE334D79-1D64-4638-B547-75400AA9A58B}.Debug|Any CPU.Build.0 = Debug|x86
{BE334D79-1D64-4638-B547-75400AA9A58B}.Debug|ARM.ActiveCfg = Debug|ARM
{BE334D79-1D64-4638-B547-75400AA9A58B}.Debug|ARM.Build.0 = Debug|ARM
{BE334D79-1D64-4638-B547-75400AA9A58B}.Debug|ARM.Deploy.0 = Debug|ARM
Expand All @@ -236,7 +228,6 @@ Global
{BE334D79-1D64-4638-B547-75400AA9A58B}.Release|x86.Build.0 = Release|x86
{BE334D79-1D64-4638-B547-75400AA9A58B}.Release|x86.Deploy.0 = Release|x86
{AA1ADA35-B0C0-4EDF-8BAD-56D1021BE922}.Debug|Any CPU.ActiveCfg = Debug|x86
{AA1ADA35-B0C0-4EDF-8BAD-56D1021BE922}.Debug|Any CPU.Build.0 = Debug|x86
{AA1ADA35-B0C0-4EDF-8BAD-56D1021BE922}.Debug|ARM.ActiveCfg = Debug|ARM
{AA1ADA35-B0C0-4EDF-8BAD-56D1021BE922}.Debug|ARM.Build.0 = Debug|ARM
{AA1ADA35-B0C0-4EDF-8BAD-56D1021BE922}.Debug|ARM.Deploy.0 = Debug|ARM
Expand Down Expand Up @@ -277,7 +268,6 @@ Global
{8F535C5F-6963-4C18-9B52-4EF5252CCC49}.Release|x86.Build.0 = Release|x86
{8F535C5F-6963-4C18-9B52-4EF5252CCC49}.Release|x86.Deploy.0 = Release|x86
{5AC4757E-2FAA-4B65-A4FB-E774B76C41AD}.Debug|Any CPU.ActiveCfg = Debug|x86
{5AC4757E-2FAA-4B65-A4FB-E774B76C41AD}.Debug|Any CPU.Build.0 = Debug|x86
{5AC4757E-2FAA-4B65-A4FB-E774B76C41AD}.Debug|ARM.ActiveCfg = Debug|ARM
{5AC4757E-2FAA-4B65-A4FB-E774B76C41AD}.Debug|ARM.Build.0 = Debug|ARM
{5AC4757E-2FAA-4B65-A4FB-E774B76C41AD}.Debug|ARM.Deploy.0 = Debug|ARM
Expand Down Expand Up @@ -438,7 +428,6 @@ Global
{AAE53064-C591-43FB-A8BE-9FED2104B98F}.Release|x86.Build.0 = Release|x86
{AAE53064-C591-43FB-A8BE-9FED2104B98F}.Release|x86.Deploy.0 = Release|x86
{F051BB74-A073-4D35-A185-B089579C52C4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F051BB74-A073-4D35-A185-B089579C52C4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F051BB74-A073-4D35-A185-B089579C52C4}.Debug|ARM.ActiveCfg = Debug|ARM
{F051BB74-A073-4D35-A185-B089579C52C4}.Debug|ARM.Build.0 = Debug|ARM
{F051BB74-A073-4D35-A185-B089579C52C4}.Debug|x64.ActiveCfg = Debug|x64
Expand Down

0 comments on commit c831433

Please sign in to comment.