相关疑难解决方法(0)

使用WPF shell集成库最大化时窗口超出屏幕

我正在使用WPF Shell集成库来创建我的wpf应用程序的自定义chrome.一切都很好,但是当最大化应用程序时,屏幕外有6或7个像素.

这是我正在使用的代码:

<Style TargetType="{x:Type local:MainWindow}">
        <Setter Property="shell:WindowChrome.WindowChrome">
            <Setter.Value>
                <shell:WindowChrome
                    ResizeBorderThickness="6"
                    CaptionHeight="10"
                    CornerRadius="0"
                    GlassFrameThickness="1"/>
            </Setter.Value>
        </Setter>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type local:MainWindow}">
                    <Grid>
                        <Border BorderThickness="1" BorderBrush="#389FD1" Background="#389FD1">
                            <ContentPresenter Margin="0,22,0,0" Content="{TemplateBinding Content}"/>
                        </Border>
                        <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" VerticalAlignment="Top" >
                            <TextBlock Text="{Binding NombreUsuario}" Foreground="White" Margin="5,5,20,5" Opacity=".8" />
                            <Button Style="{StaticResource ImageButton}" Height="20" Width="20" Margin="0" Click="WindowMinimize" shell:WindowChrome.IsHitTestVisibleInChrome="True">
                                <Image Height="10" Width="10" Source="/Resources/Images/minimize.png" />
                            </Button>
                            <Button Style="{StaticResource ImageButton}" Height="20" Width="20" Margin="0" Click="WindowMaximizeRestore" shell:WindowChrome.IsHitTestVisibleInChrome="True" >
                                <Image Height="10" Width="10" Source="/Resources/Images/maximize.png" />
                            </Button>
                            <Button Style="{StaticResource ImageButton}" Height="20" Width="20" …
Run Code Online (Sandbox Code Playgroud)

wpf .net-4.0

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

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应用程序(使用Elysium Extra)在窗口右侧有一个边距:

在此输入图像描述

在右侧,您可以看到我的桌面背景.

我检查是否有保证金,但它设置为0 px所有方面.我也定了

this.MaxWidth = SystemParameters.MaximizedPrimaryScreenWidth;
this.MaxHeight = SystemParameters.MaximizedPrimaryScreenHeight;
Run Code Online (Sandbox Code Playgroud)

App.xaml中:

<extra:ElysiumApplication x:Class="CTS.App"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:extra="http://schemas.extra.com/ui"
             xmlns:local="clr-namespace:CTS"
             Theme="Dark"
             StartupUri="MainWindow.xaml" />
Run Code Online (Sandbox Code Playgroud)

MainWindow.xaml:

<extra:Window x:Class="CTS.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:extra="http://schemas.extra.com/ui"
        xmlns:local="clr-namespace:CTS"
        mc:Ignorable="d"
        Title="..." Height="521.877" Width="1239.945" FontFamily="Open Sans" Foreground="#FF0970D1" Background="#FF22313F">

....
Run Code Online (Sandbox Code Playgroud)

编辑:我已经检查了Elysium Extra演示应用程序.它也有同样的问题,所以它似乎是由框架引起的.但是,我想继续使用它.

我怎样才能摆脱这个边际?

wpf

6
推荐指数
1
解决办法
229
查看次数

在触发器中检查窗口的"WindowState"的值

在WPF中,有没有办法检查触发器中窗口的"WindowState"属性?我尝试使用"0","最小化"和"WindowState.Minimized"的值.

例:

<Window.Triggers>
    <Trigger Property="WindowState" Value="Minimized">
        <Setter Property="ShowInTaskBar" Value="False" />
    </Trigger>
</Window.Triggers>
Run Code Online (Sandbox Code Playgroud)

c# wpf triggers windowstate

5
推荐指数
2
解决办法
4588
查看次数

标签 统计

wpf ×4

c# ×2

.net-4.0 ×1

.net-4.5 ×1

triggers ×1

window-chrome ×1

windowstate ×1

xaml ×1