I have this style:
<Style x:Key="RoundCorner" TargetType="{x:Type Button}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Grid x:Name="grid" >
<Border x:Name="border" CornerRadius="8">
<Border.Background>
SlateBlue
</Border.Background>
</Border>
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" >
<ContentPresenter.Content>
<StackPanel Orientation="Horizontal">
<Image Source="{TemplateBinding Source}"></Image>
<TextBlock HorizontalAlignment="Right" VerticalAlignment="Center" Text="{TemplateBinding Content}"/>
</StackPanel>
</ContentPresenter.Content>
</ContentPresenter>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
gjgj
And I have three buttons that use it:
<Button Style="{StaticResource RoundCorner}" Name="btnOK" Command="NavigationCommands.GoToPage" CommandParameter="ViewModel/OK.xaml" CommandTarget="{Binding ElementName=frmContent}" ></Button>
<Button Style="{StaticResource RoundCorner}" Name="btnHome" Command="NavigationCommands.GoToPage" CommandParameter="ViewModel/Home.xaml" CommandTarget="{Binding ElementName=frmContent}" ></Button>
<Button Style="{StaticResource RoundCorner}" Name="btnHelp" Command="NavigationCommands.GoToPage" CommandParameter="ViewModel/Help.xaml" CommandTarget="{Binding ElementName=frmContent}" ></Button>
I want these 3 buttons which implement the same style, to show different image and text. The first button should have image of OK and 'OK' written on it, the second button the same but for 'Home', etc. How do I do that?
Resource
xaml
Note : You can set Image Source using Tag property also
Try creating a UserControl. Here is mine, just modify it to suit your needs: XAML:
CodeBehind: