WP8.1怎么注册后退硬件啊
vb.net吧
全部回复
仅看楼主
level 13
天韵饺子 楼主
C#只要直接添加基本页就行了,而VB.NET添加了基本页也还是直接后台,怎么办[泪]
---NOKIA Lumia 920 Windows10 Mobile
2015年10月01日 05点10分 1
level 13
抄c#基本页模板的代码不就达到目的了
2015年10月01日 05点10分 2
大神好机智[滑稽]
2015年10月01日 05点10分
level 13
天韵饺子 楼主
c#:
using CSHARP_test.Common;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.Graphics.Display;
using Windows.UI.ViewManagement;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
// The Basic Page item template is documented at http://go.microsoft.com/fwlink/?LinkID=390556
namespace CSHARP_test
{
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class BasicPage1 : Page
{
private NavigationHelper navigationHelper;
private ObservableDictionary defaultViewModel = new ObservableDictionary();
public BasicPage1()
{
this.InitializeComponent();
this.navigationHelper = new NavigationHelper(this);
this.navigationHelper.LoadState += this.NavigationHelper_LoadState;
this.navigationHelper.SaveState += this.NavigationHelper_SaveState;
}
/// <summary>
/// Gets the <see cref="NavigationHelper"/> associated with this <see cref="Page"/>.
/// </summary>
public NavigationHelper NavigationHelper
{
get { return this.navigationHelper; }
}
/// <summary>
/// Gets the view model for this <see cref="Page"/>.
/// This can be changed to a strongly typed view model.
/// </summary>
public ObservableDictionary DefaultViewModel
{
get { return this.defaultViewModel; }
}
/// <summary>
/// Populates the page with content passed during navigation. Any saved state is also
/// provided when recreating a page from a prior session.
/// </summary>
/// <param name="sender">
/// The source of the event; typically <see cref="NavigationHelper"/>
/// </param>
/// <param name="e">Event data that provides both the navigation parameter passed to
/// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested and
/// a dictionary of state preserved by this page during an earlier
/// session. The state will be null the first time a page is visited.</param>
private void NavigationHelper_LoadState(object sender, LoadStateEventArgs e)
{
}
/// <summary>
/// Preserves state associated with this page in case the application is suspended or the
/// page is discarded from the navigation cache. Values must conform to the serialization
/// requirements of <see cref="SuspensionManager.SessionState"/>.
/// </summary>
/// <param name="sender">The source of the event; typically <see cref="NavigationHelper"/></param>
/// <param name="e">Event data that provides an empty dictionary to be populated with
/// serializable state.</param>
private void NavigationHelper_SaveState(object sender, SaveStateEventArgs e)
{
}
#region NavigationHelper registration
/// <summary>
/// The methods provided in this section are simply used to allow
/// NavigationHelper to respond to the page's navigation methods.
/// <para>
/// Page specific logic should be placed in event handlers for the
/// <see cref="NavigationHelper.LoadState"/>
/// and <see cref="NavigationHelper.SaveState"/>.
/// The navigation parameter is available in the LoadState method
/// in addition to page state preserved during an earlier session.
/// </para>
/// </summary>
/// <param name="e">Provides data for navigation methods and event
/// handlers that cannot cancel the navigation request.</param>
protected override void OnNavigatedTo(NavigationEventArgs e)
{
this.navigationHelper.OnNavigatedTo(e);
}
protected override void OnNavigatedFrom(NavigationEventArgs e)
{
this.navigationHelper.OnNavigatedFrom(e);
}
#endregion
}
}
2015年10月01日 06点10分 4
level 13
天韵饺子 楼主
vb.net:
Imports App1.Common
' The Basic Page item template is documented at http://go.microsoft.com/fwlink/?LinkID=390556
''' <summary>
''' A basic page that provides characteristics common to most applications.
''' </summary>
Public NotInheritable Class BasicPage1
Inherits Page
Private WithEvents _navigationHelper As New NavigationHelper(Me)
Private ReadOnly _defaultViewModel As New ObservableDictionary()
''' <summary>
''' Gets the <see cref="NavigationHelper"/> associated with this <see cref="Page"/>.
''' </summary>
Public ReadOnly Property NavigationHelper As NavigationHelper
Get
Return _navigationHelper
End Get
End Property
''' <summary>
''' Gets the view model for this <see cref="Page"/>.
''' This can be changed to a strongly typed view model.
''' </summary>
Public ReadOnly Property DefaultViewModel As ObservableDictionary
Get
Return _defaultViewModel
End Get
End Property
''' <summary>
''' Populates the page with content passed during navigation. Any saved state is also
''' provided when recreating a page from a prior session.
''' </summary>
''' <param name="sender">
''' The source of the event; typically <see cref="NavigationHelper"/>.
''' </param>
''' <param name="e">Event data that provides both the navigation parameter passed to
''' <see cref="Frame.Navigate"/> when this page was initially requested and
''' a dictionary of state preserved by this page during an earlier.
''' session. The state will be null the first time a page is visited.</param>
Private Sub NavigationHelper_LoadState(sender As Object, e As LoadStateEventArgs) Handles _navigationHelper.LoadState
' TODO: Load the saved state of the page here.
End Sub
''' <summary>
''' Preserves state associated with this page in case the application is suspended or the
''' page is discarded from the navigation cache. Values must conform to the serialization
''' requirements of <see cref="SuspensionManager.SessionState"/>.
''' </summary>
''' <param name="sender">The source of the event; typically <see cref="NavigationHelper"/></param>
''' <param name="e">Event data that provides an empty dictionary to be populated with
''' serializable state.</param>
Private Sub NavigationHelper_SaveState(sender As Object, e As SaveStateEventArgs) Handles _navigationHelper.SaveState
' TODO: Save the unique state of the page here.
End Sub
#Region "NavigationHelper registration"
''' <summary>
''' The methods provided in this section are simply used to allow
''' NavigationHelper to respond to the page's navigation methods.
''' <para>
''' Page specific logic should be placed in event handlers for the
''' <see cref="NavigationHelper.LoadState"/>
''' and <see cref="NavigationHelper.SaveState"/>.
''' The navigation parameter is available in the LoadState method
''' in addition to page state preserved during an earlier session.
''' </para>
''' </summary>
''' <param name="e">Event data that describes how this page was reached.</param>
Protected Overrides Sub OnNavigatedTo(e As NavigationEventArgs)
_navigationHelper.OnNavigatedTo(e)
End Sub
Protected Overrides Sub OnNavigatedFrom(e As NavigationEventArgs)
_navigationHelper.OnNavigatedFrom(e)
End Sub
#End Region
End Class
2015年10月01日 06点10分 5
level 13
天韵饺子 楼主
所以看起来差别只有:
public BasicPage1()
{
this.InitializeComponent();
this.navigationHelper = new NavigationHelper(this);
this.navigationHelper.LoadState += this.NavigationHelper_LoadState;
this.navigationHelper.SaveState += this.NavigationHelper_SaveState;
}
这一段VB.NET基本页里没有
然后贴进去,去掉;,改掉(),把this换成me,然后就是错误#(不高兴)(本人菜鸟勿喷)
@Nukepayload2
2015年10月01日 06点10分 6
用AddHandler ---贴吧极速版 For UWP
2015年10月01日 11点10分
回复 Nukepayload2 : 多谢啦[哈哈] -Windows10 UWP Tieba
2015年10月01日 13点10分
level 13
或者给NavigationHelper用withevents
---贴吧极速版 For UWP
2015年10月01日 11点10分 7
1