Skip to content

Instantly share code, notes, and snippets.

@mattdot
Last active November 17, 2015 20:46
Show Gist options
  • Save mattdot/42dfc975a4e11c4e98a3 to your computer and use it in GitHub Desktop.
Save mattdot/42dfc975a4e11c4e98a3 to your computer and use it in GitHub Desktop.
Sample showing how to enable back navigation by clicking the "back" in a Universal app.
//*********************************************************//
// Copyright (c) Microsoft. All rights reserved.
//
// Apache 2.0 License
//
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
// implied. See the License for the specific language governing
// permissions and limitations under the License.
//
//*********************************************************
namespace UniversalMouseBackButton
{
sealed partial class App : Application
{
protected override void OnLaunched(LaunchActivatedEventArgs e)
{
//other startup code here ...
Window.Current.CoreWindow.PointerReleased += (Windows.UI.Core.CoreWindow sender, Windows.UI.Core.PointerEventArgs args) => {
if (args.CurrentPoint.Properties.PointerUpdateKind == Windows.UI.Input.PointerUpdateKind.XButton1Released)
{
var frame = Window.Current.Content as Frame;
if (null != frame)
{
//go back
if (frame.CanGoBack)
{
frame.GoBack();
}
}
}
};
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment