标签: window-chrome

WPF WindowChrome:最大化窗口的边缘不在屏幕上

我使用WindowChrome来自定义Window.当我最大化窗口时,边缘不在屏幕上.我使用以下代码来解决此问题:

<Window x:Class="WpfApplication1.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

    <WindowChrome.WindowChrome>
        <WindowChrome CaptionHeight="50" CornerRadius="0" GlassFrameThickness="0" NonClientFrameEdges="None" ResizeBorderThickness="5" UseAeroCaptionButtons="False" />
    </WindowChrome.WindowChrome>

    <Grid>  
        <Grid.Style>
            <Style TargetType="{x:Type Grid}">
                <Setter Property="Margin" Value="0" />
                <Style.Triggers>
                    <DataTrigger Binding="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=WindowState}" Value="Maximized">
                        <Setter Property="Margin" Value="{x:Static SystemParameters.WindowResizeBorderThickness}" />
                    </DataTrigger>
                </Style.Triggers>
            </Style>
        </Grid.Style>
        <Border BorderThickness="2" BorderBrush="Blue" Background="Yellow" />
    </Grid>

</Window>
Run Code Online (Sandbox Code Playgroud)

我的问题:如何获得正确的像素数,以便边缘不在屏幕之外.

SystemParameters.WindowResizeBorderThickness包含的值不正确.

c# wpf xaml window-chrome .net-4.5

13
推荐指数
2
解决办法
3091
查看次数

WPF WindowChrome在调整大小时导致闪烁

我正在使用WindowChrome轻松快速地重新调整窗口,但问题是在调整窗口大小时会出现闪烁,特别是从左到右调整大小时.

<Window x:Class="View.Settings"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    Height="570" Width="800" WindowStartupLocation="CenterOwner"
    Background="{StaticResource DarkGrayBackground}" ResizeMode="CanResize" 
    WindowStyle="SingleBorderWindow"
    Title="Settings"
    WindowState="Normal">
<WindowChrome.WindowChrome>
    <WindowChrome 
        CaptionHeight="0"
        CornerRadius="0"
        GlassFrameThickness="1"
        UseAeroCaptionButtons="False"
        ResizeBorderThickness="5"
        NonClientFrameEdges="None"/>
</WindowChrome.WindowChrome>

<Border BorderBrush="Black" BorderThickness="1">
    <DockPanel HorizontalAlignment="Stretch" LastChildFill="True" Margin="0,0,0,0" VerticalAlignment="Stretch">
        <!--TitleBar-->
        <Border DockPanel.Dock="Top" BorderBrush="{StaticResource GrayBorder}" BorderThickness="0,0,0,1">
            <Grid Height="40" Background="{StaticResource WhiteBackground}">
                <DockPanel LastChildFill="False">
                    <Image DockPanel.Dock="Left" Margin="0,0,5,0" ></Image>
                    <Label DockPanel.Dock="Left" Content="{DynamicResource settings}" Margin="0,0,0,0" HorizontalAlignment="Center" VerticalAlignment="Center"></Label>
                    <Button DockPanel.Dock="Right" Style="{StaticResource CloseButton}" x:Name="CloseBtn"/>
                </DockPanel>
            </Grid>
        </Border>
        <!--Left Menu-->
        <Border DockPanel.Dock="Left" Width="180" Background="{StaticResource GrayBackground}" BorderBrush="{StaticResource GrayBorder}" BorderThickness="0,0,1,0">
            <DockPanel Margin="0,40,0,0"  Width="180" LastChildFill="False">
                <Button …
Run Code Online (Sandbox Code Playgroud)

c# wpf window-chrome

13
推荐指数
1
解决办法
500
查看次数

窗口模板中的边框边距与WindowChrome一起使用时没有任何效果

我正在图书馆检查WindowChrome课程System.Windows.Shell(v 3.5.41019.1).当我尝试创建Window模板时,模板中Border元素的边距似乎没有效果:

<Window x:Class="WpfApplication7.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:shell="clr-namespace:Microsoft.Windows.Shell;assembly=Microsoft.Windows.Shell"
        Title="MainWindow" Height="350" Width="525" Style="{DynamicResource WindowStyle1}">
    <Window.Resources>
        <Style x:Key="WindowStyle1" TargetType="{x:Type Window}">
<!-- Here is the WindowChrome.-->
            <Setter Property="shell:WindowChrome.WindowChrome">
                <Setter.Value>
                    <shell:WindowChrome />
                </Setter.Value>
            </Setter>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type Window}">
<!-- And here is the Border. Its margin has no effect as far as I can tell.-->
                        <Border Margin="25" Background="Red">
                            <AdornerDecorator>
                                <ContentPresenter/>
                            </AdornerDecorator>
                        </Border>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </Window.Resources>
    <Grid>

    </Grid>
</Window>
Run Code Online (Sandbox Code Playgroud)

您认为原因是什么?我想知道,因为我看到有些人使用像*这样的东西:

<Border x:Name="WindowBorder" Margin="{Binding Source={x:Static …
Run Code Online (Sandbox Code Playgroud)

c# wpf xaml windows-shell window-chrome

12
推荐指数
1
解决办法
2832
查看次数

如何在wpf,黑色边框中使用没有Windows Aero玻璃效果的WindowChrome

我正在尝试使用WindowChrome类来自定义窗口边框.没有Windows Aero玻璃效果.正如所料,我最终得到了一个黑色的寄宿生.但我最终也没有标题按钮

从Microsoft我了解到我可以通过将窗口样式设置为null来使用标准窗口来克服这些问题 http://msdn.microsoft.com/en-us/library/microsoft.windows.shell.windowchrome.aspx

但我没有成功.

有没有人有这方面的实例?或者某种类型的链接可以解释如何解决我的问题?

我试图做一个简单的示例代码,并将WindowStyle更改为none但它不起作用.这是我的示例代码:

<Window x:Class="WpfApplication1.Window1"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
        xmlns:shell="clr-namespace:Microsoft.Windows.Shell;assembly=Microsoft.Windows.Shell" Title="Window" Height="400" Width="500">
    <Window.Style>
        <Style TargetType="{x:Type Window}">
            <Setter Property="shell:WindowChrome.WindowChrome">
                <Setter.Value>
                    <shell:WindowChrome />
                </Setter.Value>
            </Setter>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type Window}">
                        <Grid>
                            <Border Background="White" Margin="{Binding Source={x:Static shell:SystemParameters2.Current}, Path=WindowNonClientFrameThickness}">
                                <ContentPresenter Content="{TemplateBinding Content}" />
                            </Border>
                            <TextBlock Text="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Title}" 
                               VerticalAlignment="Top" HorizontalAlignment="Left" 
                               Margin="36,8,0,0"/>
                            <Image Source="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Icon}"
                           VerticalAlignment="Top" HorizontalAlignment="Left"
                           Margin="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(shell:WindowChrome.WindowChrome).ResizeBorderThickness}" 
                           Width="{Binding Source={x:Static shell:SystemParameters2.Current}, Path=SmallIconSize.Width}"
                           shell:WindowChrome.IsHitTestVisibleInChrome="True"/>
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </Window.Style>
    <Grid/>
</Window>
Run Code Online (Sandbox Code Playgroud)

c# wpf .net-4.0 window-chrome aero-glass

10
推荐指数
1
解决办法
1万
查看次数

WPF:自定义窗口,标准最小/最大/关闭按钮

我想创建一个自定义WPF窗口(WindowStyle = None,allowsTransparency = True).但是,我希望min/max/close按钮看起来与标准窗口上的相同.这可能吗?

windows wpf custom-controls window-chrome

8
推荐指数
1
解决办法
2928
查看次数

在Windows 8.1上使用WindowChrome时,任务栏图标消失

我在Windows 8.1上使用自己风格的WPF窗口时遇到了一些问题.我用WindowChrome编写了一个简单的透明WPF窗口,用于默认的窗口拖动行为:

<Window x:Class="WpfApplication1.Window1"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Height="300" Width="300" Background="Transparent"
        AllowsTransparency="True" WindowStyle="None">
    <WindowChrome.WindowChrome>
        <WindowChrome />
    </WindowChrome.WindowChrome>
    <Border Background="Gray" CornerRadius="20">
        <Grid>
        </Grid>
    </Border>
</Window>
Run Code Online (Sandbox Code Playgroud)

Windows 8.1设置:

  • 2台带扩展桌面的显示器
  • 任务栏仅在主桌面上可见

摄制:

  1. 启动WPF应用程序
  2. 在辅助屏幕上移动窗口
  3. 最大化辅助屏幕上的窗口(例如,将窗口对接在顶部)
  4. 恢复窗口并将其从辅助屏幕拖动到主屏幕

- >当鼠标进入主屏幕时,任务栏图标将完全消失!

如果再次执行相同的复制,则会再次显示该图标.

我还尝试使用.NET 4.5或.NET 4.5.1!

有谁能解释这个问题?

谢谢!

wpf xaml window-chrome .net-4.5 windows-8.1

8
推荐指数
1
解决办法
1599
查看次数

使用WindowChrome在WPF窗口上显示默认窗口按钮

我发现在WPF窗口上使用WindowChrome可以使我在窗口中的任何位置放置内容,这是一个很好的想法。现在,我终于可以使标题栏具有与应用程序其余部分相同的颜色。

但是,我仍然喜欢出现在非样式窗口上的默认的最小化/最大化/关闭按钮。

有什么方法可以使用WindowChrome设置窗口样式,但仍保留默认按钮?

<Style x:Key="MainWindow" TargetType="{x:Type Window}">
    <Setter Property="WindowChrome.WindowChrome">
        <Setter.Value>
            <WindowChrome CaptionHeight="30" ResizeBorderThickness="5" />
        </Setter.Value>
    </Setter>
</Style>

<Window Style="{StaticResource MainWindow}">
    <Grid Background="Black">
        <MyContent />
    </Grid>
</Window>
Run Code Online (Sandbox Code Playgroud)

这将形成一个大的黑色窗口(很棒!),但是没有任何最小/最大/关闭按钮,因为它们隐藏在的后面Grid(不太好)。但是,这些按钮仍然可以单击,因此很明显它们在那里。

wpf xaml window-chrome

5
推荐指数
1
解决办法
2163
查看次数

为 Window 设置 WindowChrome 时未显示任务栏

我将系统任务栏设置为自动隐藏,然后在最大化状态下运行 WPF 应用程序。当应用程序处于最大化状态时,我将鼠标悬停在屏幕底部以查看任务栏,但它没有出现。找到下面的代码块。

<Window x:Class="_189619.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:_189619"

        mc:Ignorable="d" WindowState="Maximized"
        Title="MainWindow" Height="350" Width="525">
    <WindowChrome.WindowChrome>
        <WindowChrome CaptionHeight="50" ResizeBorderThickness="3"/>
    </WindowChrome.WindowChrome>
    <Grid>

    </Grid>
</Window>
Run Code Online (Sandbox Code Playgroud)

显示任务栏的任何解决方法?

提前致谢。

问候, 普里扬加 B

windows wpf wpf-controls window-chrome

5
推荐指数
0
解决办法
316
查看次数

为什么添加ContentControl会导致我的应用程序进入中断模式?

简要

我创造了一个美丽的WindowChrome风格,适用于我的窗户.ContentControl但是,当我添加到我的样式时,应用程序进入中断模式.

我已经拼凑了这个youtube视频,本文,这个SO问题微软的文档中的代码,我已经提出了以下代码.

注意:下面的代码都被认为是相关的,因为应用程序无法使用这些部分中的任何一个运行(是的,我知道它可以在没有代码隐藏的情况下运行,但是令人烦恼的是必须从Visual Studio而不是关闭按钮停止应用程序 -也是我想要完成的事情).我实际上已经缩减了下面的代码,以便更容易使用.


Window.xaml

<Style x:Key="TestWindow" TargetType="{x:Type Window}">
    <Setter Property="Background" Value="#FF222222"/>
    <Setter Property="BorderBrush" Value="WhiteSmoke"/>
    <Setter Property="BorderThickness" Value="5,30,5,5"/>
    <Setter Property="WindowChrome.WindowChrome">
        <Setter.Value>
            <WindowChrome CaptionHeight="20"
                          CornerRadius="0"
                          GlassFrameThickness="0,0,0,-1"
                          NonClientFrameEdges="None"
                          ResizeBorderThickness="5"
                          UseAeroCaptionButtons="True"/>
        </Setter.Value>
    </Setter>
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="{x:Type Window}">

                <Grid>

                    <Border Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}">
                        <AdornerDecorator>
                            <ContentPresenter/>
                        </AdornerDecorator>
                    </Border>

                    <DockPanel LastChildFill="True" VerticalAlignment="Top" Height="30">

                        <StackPanel DockPanel.Dock="Right"
                                    Orientation="Horizontal"
                                    VerticalAlignment="Center">
                            <Button x:Name="Button_Close"
                                    WindowChrome.IsHitTestVisibleInChrome="True"
                                    Width="{Binding ActualHeight, RelativeSource={RelativeSource …
Run Code Online (Sandbox Code Playgroud)

c# wpf xaml contentcontrol window-chrome

5
推荐指数
1
解决办法
402
查看次数

如何在没有隐藏控制框的情况下隐藏 WPF 功能区窗口(启用 Aero)中的标题栏?

我目前使用 WPF 功能区窗口并在当前窗口中启用 Aero,如下图所示。我喜欢隐藏“Pattern Tester”的标题,因为没有足够的空间来显示它。但是我仍然需要原始的 Windows 控制框和当前标题(即使它会被隐藏),它们将显示在任务管理器和其他相关程序(如任务切换器和任务栏)中。

WPF 功能区窗口

wpf ribbon-control window-chrome

4
推荐指数
1
解决办法
1万
查看次数

WindowChrome ResizeBorderThickness问题

我正在构建一个Window,但我注意到WindowChrome的这种奇怪的行为(在.NET FW 4.0中,来自外部的Microsoft.Windows.Shell dll).

我使用AllowTransparency = true和WindowStyle = None设置WindowChrome.

如果我设置WindowChrome的ResizeBorderThickness <= 7一切都很完美,但如果我这样做

ResizeBorderThickness="8"

或者更多,当窗口最大化时,我无法将其从屏幕上边缘附近的最后一个顶部像素拖动,并且对于每个超过7的+1,我必须开始从边缘向下拖动1个像素.

这很烦人,因为它在关闭窗口时禁用了常见的行为,迫使我将其设置为7或更低.

有人可以解释我这种行为吗?

谢谢!

wpf xaml windows-shell .net-4.0 window-chrome

4
推荐指数
1
解决办法
3248
查看次数

如何使用C#代码而不是XAML启用窗口镶边?

所以我使用WPFShell将chrome应用于自定义窗口.我从这篇文章中了解到,为了使用它,我必须引用Microsoft.Windows.Shell库并使用这个XAML代码:

<shell:WindowChrome.WindowChrome>
    <shell:WindowChrome
    ResizeBorderThickness="6"
    CaptionHeight="43"
    CornerRadius="25,25,10,10"
    GlassFrameThickness="0">
    </shell:WindowChrome>
</shell:WindowChrome.WindowChrome>
Run Code Online (Sandbox Code Playgroud)

我的问题是,如何使用C#代码而不是XAML启用chrome?(即如何在代码隐藏中应用chrome?)

c# wpf xaml window-chrome

3
推荐指数
2
解决办法
3602
查看次数

在wpf中定制镀铬的Windows

我尝试使用WindowStyle None和AllowTransparency True在wpf中创建一个定制的镀铬窗口,然而,当我最大化窗口时它覆盖整个屏幕(并且它的边缘,它还隐藏了我的底部的Windows栏)屏幕,就像全屏游戏一样).我如何使行为像普通窗口一样,但我自己定制的wpf-chrome?

wpf window-chrome

2
推荐指数
1
解决办法
3256
查看次数