从设置在WPF窗口标题不同的任务栏的文本 [英] Set a taskbar text different from the Window title in wpf

查看:740
本文介绍了从设置在WPF窗口标题不同的任务栏的文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我VS2010开发C#和我想创建一个具有窗口标题不同的任务栏文本的WPF窗口。
同时设置窗口标题和任务栏的文本属性称号。有没有一种方法来设置他们separatly

I develop with VS2010 in C# and I would like to create a WPF Window which have a taskbar text different from the Window title. The property Title set both the window title and the taskbar text. Is there a way to set them separatly?

推荐答案

首先,我要加强什么科迪灰色在他的回答和评论都表示,? - 这是不规范的行为,你应该有一个不错的理由这样做。

First, let me reinforce what Cody Gray said in both his answer and comment - this is non-standard behavior, and you should have a darn good reason for doing this.

话虽这么说,我会采取近乎相反的做法,以科迪的观点#1 。我想创建一个窗口,WindowStyle设置为无,并重新创建标题栏(其中可能包括图标,你的伪称号,最小化,最大化和关闭按钮,甚至标准的Windows菜单中,您还需要处理调整(这可以通过设置ResizeMode到CanResizeWithGrip做,但它增加了一个手柄控制你的窗口的底部,这使得它看起来比正常窗口略有不同)。

That being said, I would take a nearly opposite approach to Cody's point #1. I would create a window WindowStyle set to None, and recreate the title bar (which could include the icon, your "pseudo-title," minimize, maximize, and close buttons, and perhaps even the standard Windows menu. You will also need to handle resizing (which can be done by setting ResizeMode to CanResizeWithGrip, but it adds a Grip control to the bottom of your window, which makes it look slightly different than a "normal" window).

这个窗口,则是要在任务栏显示标题,并在您创建只会被绑定到任何你想要的标签或TextBlock的标题栏中的伪冠军称号属性的窗口来显示。

The Title property of this window would then be the Title you want to show in the Taskbar, and the "pseudo-title" in the title bar you create would just be a Label or TextBlock bound to whatever you want your window to show.

这是一个有点复杂,但真的不太难的事情。你可能会碰到一些沿途的陷阱(例如,如何窗口看起来不同的操作系统或应用了不同的Windows主题)。这种做法的好处是,它不需要互操作,并且可以只使用XAML来实现多数吧。

It is a little complex, but really not too difficult to do. You will probably run into some Gotchas along the way (for instance, how the Window looks on different OS's or with different Windows themes applied). The nice thing is that it requires no Interop, and a majority of it can be attained using XAML only.

有有很多的例子在线(这里一个我在挑随机)。

There are lots of examples online (here is one I picked at random).

同样,你要决定是否值得创建一个不规范的行为的努力。情况因人而异。

Again, you'll have to decide if it is worth the effort to create a non-standard behavior. YMMV.

这篇关于从设置在WPF窗口标题不同的任务栏的文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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