Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set Background in StackPanel

Tags:

c#

wpf

stackpanel

Please anyone let me know how to set image in stack panel background in xaml ? I have already tried the following it throwing an error that Background does not have property 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>
like image 425
Thorin Oakenshield Avatar asked Sep 22 '10 09:09

Thorin Oakenshield


2 Answers

Try this

<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>
like image 178
rudigrobler Avatar answered Oct 21 '22 20:10

rudigrobler


You need to use an image brush

like image 44
vc 74 Avatar answered Oct 21 '22 19:10

vc 74