首页 > 解决方案 > 窗口最大化时无法拖动到其他显示器

问题描述

我的 WPF 生成的窗口一旦最大化,就不能移动到另一个窗口,除非它首先取消最大化。

我基本上已经删除(并添加回)窗口属性中的每个元素,看看它是否会影响它。

<Window x:Class="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:DriverChat"
    mc:Ignorable="d" 
    Title="Geotab Messages" 
    Height="600" 
    Width="1080" 
    Loaded="Window_Loaded" 
    Icon="Chat.ico" 
    WindowStyle="SingleBorderWindow" 
    WindowState="Normal" 
    WindowStartupLocation="CenterScreen" 
    Background="#FF363E47"
    >
<WindowChrome.WindowChrome>
    <WindowChrome 
        CaptionHeight="0" 
        ResizeBorderThickness="5" 
        UseAeroCaptionButtons="False"/>
</WindowChrome.WindowChrome>
<Grid x:Name="windowGrid">
    <Grid.RowDefinitions>
        <RowDefinition Height="31"/>
        <RowDefinition Height="*" />
    </Grid.RowDefinitions>
    <ContentControl x:Name="TitleBar">
        <Border 
            Grid.Row="0" 
            Background="#FF363E47" 
            HorizontalAlignment="Stretch" 
            Height="31" 
            VerticalAlignment="Top">
            <Label 
                Content="Geotab Messages (BETA)" 
                FontSize="12" 
                FontWeight="Normal" 
                HorizontalContentAlignment="Center" 
                Margin="47,0" 
                Padding="5,3" 
                Foreground="#FFF7F7F7" 
                HorizontalAlignment="Left" 
                VerticalContentAlignment="Center"
                />
        </Border>
    </ContentControl>
<StackPanel Grid.Row="0" Grid.Column="2" Orientation="Horizontal"  HorizontalAlignment="Right">
        <Button Style="{StaticResource Square}" x:Name="btnMin" Content="—" HorizontalAlignment="Right" Width="48" Background="#FF363E47" Foreground="#FFF7F7F7" BorderThickness="0" BorderBrush="Transparent"/>
        <Button Style="{StaticResource Square}" x:Name="btnMax" Content="⃞" FontSize="14" HorizontalAlignment="Right" Width="48" Background="#FF363E47" Foreground="#FFF7F7F7" BorderThickness="0" BorderBrush="Transparent" />
        <Button Style="{StaticResource Square}" x:Name="btnClose" Content="✕" FontSize="14" HorizontalAlignment="Right" Width="48" Background="#FF363E47" Foreground="#FFF7F7F7" BorderThickness="0" BorderBrush="Transparent"/>
    </StackPanel>

解决方案:

在 WindowChrome 部分中,captionHeight 需要更改为非零值,以使其可供用户访问。

标签: wpfxaml

解决方案


推荐阅读