简体   繁体   English

WPF无边框窗口按钮

[英]WPF Borderless window buttons

I have a WPF window which is without the window chrome, so I have implemented custom window controls, like here (I'm going to style them later): 我有一个没有窗口镶边的WPF窗口,因此我实现了自定义窗口控件,例如此处(我将在以后设置其样式):

The XAML for this is: XAML为此:

                <StackPanel Orientation="Horizontal" Grid.Column="2" FlowDirection="RightToLeft">
                    <Button FontFamily="Marlett" FontSize="16" VerticalAlignment="Top" Foreground="White" Background="Black" Width="40">r</Button>
                    <Button FontFamily="Marlett" FontSize="16" VerticalAlignment="Top" Foreground="White" Background="Black" Width="30">1</Button>
                    <Button FontFamily="Marlett" FontSize="16" VerticalAlignment="Top" Foreground="White" Background="Black" Width="30">0</Button>
                </StackPanel>

However, I want the icons that are used in the native Windows chrome. 但是,我想要在本机Windows chrome中使用的图标。 Here's an example in Spotify: 这是Spotify中的示例:

As you can see, they look a lot like the Windows buttons, and they fit right in with the background gradient. 如您所见,它们看起来很像Windows按钮,并且恰好适合于背景渐变。

Is there a way this can be implemented in WPF, or is there a place I can obtain the Windows window options images/glyphs? 有没有一种可以在WPF中实现的方法,或者有什么地方可以获取Windows窗口选项图像/字形?

您可以使用SystemColors获得用户的颜色首选项。

Set the backgrounds of your buttons to be transparent, and the gradient of the background will shine straight through. 将按钮的背景设置为透明,背景的渐变将直接照亮。 Don't forget to set IsHitTestVisible to True, though. 不过,不要忘记将IsHitTestVisible设置为True。 Transparent buttons can't be pressed unless IsHitTestVisible is true; 除非IsHitTestVisible为true,否则不能按下透明按钮。

You can find the XAML for those button icons by looking into the XAML file for the default Aero WPF theme. 通过查看XAML文件中的默认Aero WPF主题,可以找到这些按钮图标的XAML。 You can download the XAML for all of the themes... there is a nice list of them found in this post . 您也可以下载XAML所有的主题...有他们的一个很好的列表中找到这篇文章

Look in the ControlTemplate for the x:Type Window to find that XAML. ControlTemplate查找x:Type Window以找到该XAML。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM