Setting WPF control background image using styles?
- by aviv
Hi,
I have a set of buttons inside a stack panel. I want them all to have a background image. How can i do it using styles? since i don't want to set manually the Background image for each button.
Here is a code snippet:
<StackPanel Orientation="Horizontal" Height="100px" VerticalAlignment="Top">
<StackPanel.Resources>
<Style TargetType="Button">
<Setter Property="Margin" Value="2,4" />
</Style>
</StackPanel.Resources>
<Button Width="127px" Height="79px" VerticalAlignment="Bottom">
<Button.Background>
<ImageBrush ImageSource="images/Tab.png" />
</Button.Background>
</Button>
<Button>A</Button>
<Button>R</Button>
<Button>S</Button>
</StackPanel>
Thanks.