Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
WPF DockPanel IsMouseOver仅在将子控件滑过时触发_Wpf_Xaml - Fatal编程技术网

WPF DockPanel IsMouseOver仅在将子控件滑过时触发

WPF DockPanel IsMouseOver仅在将子控件滑过时触发,wpf,xaml,Wpf,Xaml,我的应用程序有一种瓷砖系统。请参阅以下代码: <WrapPanel Grid.Column="0" Grid.Row="1"> <DockPanel Style="{StaticResource Panel}"> <Label Content="Upload"/> <Image Width="40"> <Image.Source> <B

我的应用程序有一种瓷砖系统。请参阅以下代码:

<WrapPanel Grid.Column="0" Grid.Row="1">
    <DockPanel Style="{StaticResource Panel}">
        <Label Content="Upload"/>
        <Image Width="40">
            <Image.Source>
                <BitmapImage DecodePixelWidth="40" UriSource="images/download.png" />
            </Image.Source>
        </Image>
    </DockPanel>
</WrapPanel>

如你所见,我得到了主容器([icode]WrapPanel[/icode]),然后我得到了多个[icode]DockPanel[/icode],它们构成了瓷砖本身

出于某种原因,当我将鼠标移到DockPanel上时,IsMouseOver触发器不会触发,但当我将鼠标移到它的任何子项上时,它会触发。一旦触发,它将保持触发状态,直到我的鼠标离开DockPanel

风格如下:

<Style x:Key="Panel" TargetType="DockPanel">
    <Setter Property="Margin" Value="4" />
    <Setter Property="Cursor" Value="Hand" />
    <Setter Property="Height" Value="118" />
    <Setter Property="Width" Value="118" />
    <Setter Property="LastChildFill" Value="True" />
    <Style.Triggers>
        <Trigger Property="IsMouseOver" Value="True">
            <Setter Property="Background" Value="#FF212121" />
        </Trigger>
    </Style.Triggers>
    <Style.Resources>
        <Style TargetType="Label">
            <Setter Property="Foreground" Value="White" />
            <Setter Property="HorizontalAlignment" Value="Center" />
            <Setter Property="VerticalAlignment" Value="Bottom" />
            <Setter Property="Margin" Value="3" />
            <Setter Property="DockPanel.Dock" Value="Bottom" />
        </Style>
    </Style.Resources>
</Style>


有什么想法吗

尝试将DockPanel的背景设置为透明。
当背景为空时,WPF将不将其包含在中

尝试将DockPanel背景设置为透明。谢谢!作为回答:)