2012-11-26 115 views
1

我想在image1圖像的頂部製作GameArea畫布。我試圖改變ZIndex並手動拖動畫布到圖像的頂部,但都不起作用,畫布一直回到圖像的版權。如何在WPF中的圖像上製作透明畫布?

(很抱歉,如果我的英語是非常笨拙,希望你明白我的意思)

下面是我的代碼:

<Window x:Class="TugasBesarTAM_Moses_1072089.MainWindow" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    Title="Brickbreaker" Height="420" Width="375" Loaded="Window_Loaded" 
    KeyDown="Window_KeyDown" ResizeMode="NoResize"> 
<DockPanel>  
    <Grid Width="350" Height="30" 
      DockPanel.Dock="Top" 
      ShowGridLines="True"> 

     <Grid.ColumnDefinitions> 
      <ColumnDefinition/> 
      <ColumnDefinition/> 
     </Grid.ColumnDefinitions> 
     <Grid.RowDefinitions> 
      <RowDefinition/> 
     </Grid.RowDefinitions> 

     <TextBlock x:Name="txtLevel" 
        Text="Level 00" 
        Grid.Column="0" Grid.Row="1" 
        FontSize="20" FontWeight="Medium" 
        HorizontalAlignment="Left"/> 
     <TextBlock x:Name="txtScore" 
        Text="0" 
        Grid.Column="1" Grid.Row="1" 
        FontSize="20" FontWeight="Medium" 
        HorizontalAlignment="Right"/> 
    </Grid> 
    <Image Height="300" Name="image1" Stretch="Fill" Width="320" Visibility="Visible" Source="/TugasBesarTAM_Moses_1072089;component/Images/Back1.jpg" Panel.ZIndex="1" /> 
    <Canvas x:Name="GameArea" DockPanel.Dock="Bottom" Width="320" Height="300" Panel.ZIndex="0"> 

    </Canvas> 
</DockPanel> 

感謝您的關注和支持!

回答

3

在這種情況下,Dockpanel不適合使用。改用Grid。 sth like:

<Grid> 
    <Image /> 
    <Canvas /> 
</Grid>