代码之家  ›  专栏  ›  技术社区  ›  Thorin Oakenshield

如何在StackPanel中设置背景

  •  5
  • Thorin Oakenshield  · 技术社区  · 14 年前

    请任何人让我知道如何设置在xaml的堆栈面板背景图像?我已经试过以下方法了 Background 没有属性 Image

       <Button.ToolTip>
            <StackPanel Height="200" Width="200">
                <StackPanel Height="30" Width="200" Orientation="Horizontal" HorizontalAlignment="Left" VerticalAlignment="Top" >
                    <StackPanel.Background>
                        <Image Source="E:\R\watermark9.bmp"></Image>
                    </StackPanel.Background>
                    <Image VerticalAlignment="Top"  Width="30" Height="30" Source="E:\My Projects\Interconnect_New\Interconnect\Resources\watermark9.bmp" Name="image1" />
                    <TextBlock FontFamily="Aharoni" FontSize="24" FontWeight="Bold" Foreground="Black" TextWrapping="Wrap" VerticalAlignment="Top" Height="30" HorizontalAlignment="Right" Width="143">
                        <Run FontFamily="Andalus" FontSize="18" FontWeight="Normal" Text="Hello! Fancy Tip" />
                    </TextBlock>
                </StackPanel>
              </StackPanel>
        </Button.ToolTip>
    
    2 回复  |  直到 14 年前
        1
  •  14
  •   rudigrobler    14 年前

    试试这个

    <Button.ToolTip>
        <StackPanel Height="200" Width="200">
            <StackPanel Height="30" Width="200" Orientation="Horizontal" HorizontalAlignment="Left" VerticalAlignment="Top" >
                <StackPanel.Background>
                    <ImageBrush ImageSource="E:\R\watermark9.bmp" />
                </StackPanel.Background>
                <Image VerticalAlignment="Top"  Width="30" Height="30" Source="E:\My Projects\Interconnect_New\Interconnect\Resources\watermark9.bmp" Name="image1" />
                <TextBlock FontFamily="Aharoni" FontSize="24" FontWeight="Bold" Foreground="Black" TextWrapping="Wrap" VerticalAlignment="Top" Height="30" HorizontalAlignment="Right" Width="143">                    <Run FontFamily="Andalus" FontSize="18" FontWeight="Normal" Text="Hello! Fancy Tip" /></TextBlock>
            </StackPanel> 
        </StackPanel>
    </Button.ToolTip>
    
        2
  •  9
  •   vc 74    14 年前

    你需要使用 image brush