我正在使用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) 我使用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包含的值不正确.
我试图弄清楚如何以编程方式判断Windows 7机器是否启用了触控功能.是否有任何触摸API(托管或非托管)可以帮助我实现这一目标?或者我可以检查注册表中的某些内容?