WPF窗体设计不符合微软自己的UX Guide
冲突的地方就在于窗体应该不应该有左上角的图标?不知大家平时有没有注意这个问题?
这个谁说都没有用,看看微软的已经有的软件,主窗体都有,从主窗体弹出的绝大多数子窗体都没有。再来看看微软自己的UX Guide上是怎么说的。
Title bars
● Dialog boxes don’t have title bar icons. Title bar icons are used as a visual distinction between primary windows and
secondary windows.
m Exception: If a dialog box is used to implement a primary window (such as a utility) and therefore appears on the taskbar, it does have
a title bar icon. In this case, optimize the title for display on the taskbar by concisely placing the distinguishing information first.
Page 421 in pdf
Title bar icons
● Dialog boxes don’t have title bar icons.
m Exception: If a dialog box is used to implement a primary window (such as a utility) and therefore appears on the taskbar, it does have
a title bar icon.
Page 426 in pdf
Icons
● Modal error message dialogs don’t have title bar icons. Title bar icons are used as a visual distinction between primary windows
and secondary windows.
Page 541 in pdf
程序里的不在任务栏里的弹出框实在是太常见了,而现有的程序和UX Guide都告诉我们这个弹出框上不应该有左上角的Icon。好,知道了,以后这么做就是了。
等等,WPF的Window不愿意给你这个机会!看看WPF的MSDN上是怎么说的。
A WPF window always displays an icon. When one is not provided by setting Icon, WPF chooses an icon to display based on the following rules:
- Use the assembly icon, if specified.
- If the assembly icon is not specified, use the default Microsoft Windows icon.
得,微软自己两个TEAM打起来了。说直接点就是,WPF的Window没有WinForm里Form里的ShowIcon属性。
当然人不能让尿憋死,办法总是有的。不过要直接调用Win32 API。介绍在这里。我在项目里也试了一下(毕竟UX优先级高些),不是很好用。后来看了看Form里的ShowIcon方法是如何实现的才正确地解决了。要在上面的方法的基础上,SetWindowPos之后,再用下面的代码给Window发两个消息。
SendMessage(hwnd, 0x80, 0, 0);
SendMessage(hwnd, 0x80, 1, 0);
才能把Icon删掉。