我正在使用DevExpress12.2开发MetroUI喜欢的Windows 7应用程序。 但是,我面临的问题似乎无法由我自己解决。
我正在使用DocumentManager创建Tile Container Page。 因此,DevExpress会自动为我们生成一个后退按钮。
用户可以随时单击后退按钮返回到平铺菜单。 但是,在某些情况下,例如数据输入,我们需要强制用户不要回到用户完成操作之前?
当用户点击后退按钮时,是否有任何可以捕获的事件? 或者有什么方法可以在某种情况下隐藏后退按钮?
答案 0 :(得分:1)
没有嵌入式功能来处理“后退”按钮单击,因为Windows UI Navigation concepts不接受根据已经显示这些操作后更改的条件执行或不执行的操作。所有操作(导航栏操作和嵌入式操作,如“后退”按钮)都是基于其 CanExecute()方法实现显示或不显示的。
换句话说,如果您需要取消“返回”操作,则不应该显示此操作(要删除“返回”导航元素,您应该清除特定的“父”属性容器)。
因此,为了防止用户使用“后退”或“主页”导航操作停用页面内容容器,您不应将此页面内容容器包含到navigation hierarchy中并导航到此容器并从此容器返回手动,使用WindowsUIView.Controller方法和custom buttons:
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
}
}