WPF的标准命令 - 在哪里退出? [英] WPF Standard Commands - Where's Exit?

查看:150
本文介绍了WPF的标准命令 - 在哪里退出?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的WPF应用程序创建一个标准的菜单。

I'm creating a standard menu in my WPF application.

我知道我可以创建自定义的命令,但我知道也有绑定到一堆标准命令。

I know that I can create custom commands, but I know there are also a bunch of standard commands to bind to.

例如,打开一个文件,我应该绑定到 ApplicationCommands.Open ,收我应绑定到 ApplicationCommands.Close 的文件。还有大量的 EditCommands ComponentCommands NavigationCommands

For example, to open a file I should bind to ApplicationCommands.Open, to close a file I should bind to ApplicationCommands.Close. There's also a large number of EditCommands, ComponentCommands or NavigationCommands.

似乎没有成为一个退出命令。我本来期望那里是 ApplicationCommands.Exit

There doesn't seem to be an "Exit" command. I would have expected there to be ApplicationCommands.Exit.

我应该怎么绑定到退出菜单项?要创建这个东西一般只是似乎是错误的自定义命令。

What should I bind to the "Exit" menu item? To create a custom command for something this generic just seems wrong.

推荐答案

AFAIK有没有ApplicationCommands.Quit或ApplicationCommands.Exit,所以我想你得自己创建它...

AFAIK there's no ApplicationCommands.Quit or ApplicationCommands.Exit, so I guess you're gonna have to create it yourself...

无论如何,如果你正在使用的 MVVM模式,RoutedCommands并不完全得心应手,所以最好使用轻量级替代喜欢的 RelayCommand DelegateCommand

Anyway, if you're using the MVVM pattern, RoutedCommands are not exactly handy, so it's better to use a lightweight alternative like RelayCommand or DelegateCommand.

这篇关于WPF的标准命令 - 在哪里退出?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆