Windows UI ナビゲーションの概念では、実行されるアクションや、これらのアクションが既に表示された後に変化する条件に基づいていないアクションを受け入れないため、[戻る] ボタンのクリックを処理する組み込み機能はありません。すべてのアクション (ナビゲーション バーのアクションと「戻る」ボタンなどの埋め込みアクション) が表示されるかどうかは、そのCanExecute()メソッドの実装 に基づいています。
つまり、「戻る」アクションをキャンセルする必要がある場合は、このアクションをまったく表示しないでください(「戻る」ナビゲーション要素を削除するには、特定のコンテナーの Parent プロパティをクリアする必要があります)。
したがって、ユーザーが [戻る] または [ホーム] ナビゲーション アクションを使用してページ コンテンツ コンテナーを非アクティブ化できないようにするには、このページ コンテンツ コンテナーをナビゲーション階層に含めて、このコンテナーに移動したり、WindowsUIView.Controller を使用して手動でこのコンテナーから戻ったりしないでください。メソッドとカスタム ボタン:
WindowsUIButton customBackButton;
public Form1() {
InitializeComponent();
// add custom button on 'page1' container
customBackButton = new DevExpress.XtraBars.Docking2010.WindowsUIButton();
customBackButton.Caption = "Back to Main Tile Container";
customBackButton.Image = ContentContainerAction.Back.Image;
page1.Buttons.Add(customBackButton);
page1.ButtonClick += Page_ButtonClick;
tileContainer1.Click += TileContainer_Click;
}
void TileContainer_Click(object sender, TileClickEventArgs e) {
page1.Document = ((Tile)e.Tile).Document;
page1.Subtitle = ((Tile)e.Tile).Document.Caption;
// handle 'tileContainer1' click to activate 'page1' manually
e.Handled = windowsUIView1.Controller.Activate(page1);
}
const string messageText = "Do you want to navigate back in Main Tile Container?";
void Page_ButtonClick(object sender, ButtonEventArgs e) {
if(e.Button == customBackButton) {
if(MessageBox.Show(messageText, "Back", MessageBoxButtons.YesNo) == DialogResult.Yes)
windowsUIView1.Controller.Activate(tileContainer1); // activate container
}
}