I need to have a button with an image and some text in it, lets call it `MyButton`. The button colour, position of the image, position of the text, size of the image and font size remain the same every time `MyButton` is displayed. However the image source and text will be different every time. Finally, the opacity of the button needs to be set to 0.2 when disabled, and back to 1 when enabled.

My approach so far (please correct me if there is a better way) is to create a XAML file with code behind that inherits the `Button` class. My XAML is similar to:

```
<Button x:Class="MyButton"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="400">

    <!--Blank template for a flat borderless button-->
    <Button.Template>
        <ControlTemplate TargetType="Button"/>
    </Button.Template>

    <Grid Background="#F2F2F2">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto"/>
            <ColumnDefinition Width="*"/>
        </Grid.ColumnDefinitions>

        <Image Name="ImgControl" Width="32" Height="32" Grid.Column="0"/>

        <TextBlock Name="Label" VerticalAlignment="Center" Grid.Column="1"/>

    </Grid>
</Button>

```

And code behind:

```
Partial Public Class MyButton
Inherits Button

Private _imgSrc As String
Public Property ImageSource As String
    Get
        Return _imgSrc
    End Get
    Set(value As String)
        _imgSrc = value
        Dim imgUri As New Uri(_imgSrc, UriKind.RelativeOrAbsolute)
        ImgControl.Source = New BitmapImage(imgUri)
    End Set
End Property

Public Property ButtonText As String
    Get
        Return Label.Text
    End Get
    Set(value As String)
        Label.Text = value
    End Set
End Property
End Class

```

So whenever I use it in XAML I only need to declare the button, the ImageSource and the ButtonText properties.

This works fine so far but I'm having trouble with setting the opacity when the button is enabled/disabled. I've tried converters with not much luck. Any suggestions?

Thanks