如何在网格上叠加图像?

时间:2011-03-20 08:39:29

标签: c# wpf

我想在网格上叠加图像。像这样的代码:

<Grid>
<UniformGrid>
    <control:ImageButton Width="150" Height="150" Image="/MyStyle;component/Resources/Button1.png" Tag="Playlists" Click="Button_Click" />
    <control:ImageButton Width="150" Height="150" Image="/MyStyle;component/Resources/Button2.png" Tag="Now Playing" Click="Button_Click" />
    <control:ImageButton Width="150" Height="150" Image="/MyStyle;component/Resources/Button3.png" Tag="Artists" Click="Button_Click" />
    <control:ImageButton Width="150" Height="150" Image="/MyStyle;component/Resources/Button4.png" Tag="Genius Mixes" Click="Button_Click" />
</UniformGrid>
<Border>
    <Border.Background>
        <ImageBrush ImageSource="/MyStyle;component/Resources/reflect.png" />
    </Border.Background>
</Border>

问题是,按钮无法获取任何消息,怎么能解决这个问题?
任何的想法?感谢。

1 个答案:

答案 0 :(得分:2)

您需要在覆盖元素上将IsHitTestVisible设置为false

<Border IsHitTestVisible="False">
    <Border.Background>
        <ImageBrush ImageSource="/MyStyle;component/Resources/reflect.png" />
    </Border.Background>
</Border>