0
正如在oficial doc中提到的,有可能處理返回按鈕按下,但我無法處理它只做我的邏輯不回去。所以我的代碼如下所示:覆蓋後退按鈕按uwp
//declare event
public event EventHandler<BackRequestedEventArgs> BackRequested;
public MainPage() {
InitializeComponent();
// tie my event with back action
SystemNavigationManager.GetForCurrentView().BackRequested += OnBackRequested;
}
// handle the back event
private void OnBackRequested(object sender, BackRequestedEventArgs e) {
//need to do only my logic here - do NOT go back
}
所以有一種方法來獲得這種行爲。我想它由於Android做到這一點:
@Override
public void onBackPressed() {
//does only my logic
}
'e.Handled = true;'這就是我所需要的,thx – Choletski