I imagine you can draw prety much anything with enough XAML experience, but i'm a C++ guy new to WPF. I need a button that has a gradient color plus a special border around it. So what do us C++ guys do? We go to the designer, ask for a Left vertical image, Middle one and Right one, and then overriding the Win32 drawing messages practically draw the button ourselves.
What is the WPF way of doing this? Do I need to master XAML for this, or can I somehow make use of those 3 images to make up a button? My naive thought was doing something like this, were i divide the button in 3 parts, each having a different background stretched across, but that didn't give me the results I want. Can I have control of how a button is drawn?
<Style x:Key="NavButtonStyle" TargetType="{x:Type Button}">
<Setter Property="OverridesDefaultStyle" Value="True" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Grid ShowGridLines="False">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid Grid.Column="0">
<Grid.Background>
<ImageBrush ImageSource="/Images/left.png"/>
</Grid.Background>
</Grid>
<StackPanel Grid.Column="1" HorizontalAlignment="Center" Orientation="Horizontal">
<StackPanel.Background>
<ImageBrush Stretch="Fill" ImageSource="/Images/middle.png"/>
</StackPanel.Background>
<Image Source="/Images/Icons/myIcon.png"/>
<TextBlock Text="myCaption"/>
</StackPanel>
<Grid Grid.Column="2">
<Grid.Background>
<ImageBrush Stretch="Fill" ImageSource="/Images/right.png"/>
</Grid.Background>
</Grid>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
The other problem is how to make this a generic template so that I can duplicate the look and feel but just change the icon and text. I suppose the right way of doing this task is come up with a CustomControl class inheriting from Button?