在WPF中使用WindowChrome库 [英] Using WindowChrome Library in WPF

查看:761
本文介绍了在WPF中使用WindowChrome库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨朋友

祝大家新年快乐。 :)

最近,我已经加入了基于WPF的开发,目前我正在尝试设计一个自定义的应用程序。我不想要Windows 7 Style Chrome(Window Border)。所以,我使用 WindowChrome 库,可通过 Microsoft.Windows.Shell 获得。



现在,这就是我被困的地方。我用了



MainWindow.xaml

Hi Friends
A very Happy New Year to everyone. :)
Recently, I have jumped into WPF based development and I currently I am trying to design a custom looking Application. I don't want Windows 7 Style Chrome (the Window Border). So, I am using WindowChrome Library which is available via Microsoft.Windows.Shell.

Now, here's where I am stuck. I have used

MainWindow.xaml

<shell:WindowChrome GlassFrameThickness="0" />



这实际上隐藏了窗口周围的玻璃边框。

然后,我创建了几个标签,以便它们代表窗口的最小化,最大化和关闭按钮。

第二点是,我将这些标签的鼠标事件定义为窗口最右侧的三个不同按钮,当我使用它时它们正在工作


This actually hides the Glass Border around the Window.
Then, I created few labels so that they represent the Minimize, Maximize and Close Buttons of a Window.
The Second point is, I defined the mouse events for these Labels to behave as the three different buttons present on rightmost side of the Window and they were working when I was using this

<Window.WindowStyle>None</Window.WindowStyle>



但是当我使用WindowChrome时,我将其设置回


but When I used WindowChrome I set it back to

<Window.WindowStyle>SingleBorderWindow</Window.WindowStyle>



现在, WindowChrome 我上面使用的类,它隐藏了Chrome(玻璃边框)但是那里肯定是原始按钮和我的自定义控件(标签)和鼠标事件的一些重叠问题现在没有在我的标签上触发,因此,我无法以这种方式使用它们。



现在,我试图以某种方式将这些标签的click事件连接到普通Window的相应按钮所以,它们只表现为原始控件的蒙皮。



以下是我设计的截图 点击此处



请给我一些指示,以便继续前进。

非常感谢大家。



有问候

Tushar Srivastava


Now, The WindowChrome Class I used as shown above, it hide the Chrome (The glass border) but there is surely some overlapping issues with the original buttons and my custom made controls (the labels) and the mouse event is not firing on my labels now and so, I am unable to use them that way.

Now, I am trying to somehow connect the click event of these labels to the respective buttons of a normal Window So, that they only behave as a skinning to the original control.

Here is a screenshot of my design Click Here

Please give me some pointers to move ahead.
A very Thank you to everyone.

With Regards
Tushar Srivastava

推荐答案

我不确定你是如何设置标签的(如果你使用标签,文本块或什么),你应该真正发布部分的代码不要工作而不是工作的部分...



在您的XAML中:



I'm not exactly sure how you have your labels set up (if you are using label, or textblock, or what), you should really post the code for the parts that don't work rather than for the parts that do...

In your XAML:

<label mouseup="Close_MouseUp" />
<label mouseup="Minimize_MouseUp" />
<label mouseup="Maximize_MouseUp" />





在您的代码隐藏中:





In your code-behind:

private void Close_MouseUp(object sender, MouseButtonEventArgs e)
{
    this.Close();
}

private void Maximize_MouseUp(object sender, MouseButtonEventArgs e)
{
    if (this.WindowState == System.Windows.WindowState.Maximized)
        this.WindowState = System.Windows.WindowsState.Normal;
    else
        this.WindowState = System.Windows.WindowsState.Maximized;
}

private void Minimize_MouseUp(object sender, MouseButtonEventArgs e)
{
    this.WindowState = System.Windows.WindowsState.Minimized;
}





我认为没有办法将标签的click事件直接绑定到实际按钮的窗口。如果有,其他人会有更好的答案。



I don't think there is a way to directly bind the click event of the label to the actual buttons of the window. If there is, somebody else will have a better answer.


这篇关于在WPF中使用WindowChrome库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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