views:

20

answers:

1

I am making a template control so that I can have a button with an image that changes when you click it. I also am trying to get text on top of the button that can change at run time. I have the button images and everything working but I can't seem to get that label at runtime so I can change the text. Here is the code in the xaml. I am missing the code behind

<UserControl.Resources>
    <ControlTemplate TargetType="{x:Type Button}" x:Key="ActionButton">
        <Grid>
            <Label Panel.ZIndex="2" HorizontalAlignment="Center" VerticalAlignment="Center" FontFamily="Arial" Name="lblText" Foreground="#5E4421" FontWeight="Bold" FontSize="14">Test</Label>
            <Image Name="Normal" Source="/AssaultWare.Controls;component/Replayer/Images/button_off.png"/>
            <Image Name="Pressed" Source="/AssaultWare.Controls;component/Replayer/Images/button_on.png"/>
            <Image Name="Disabled" Source="/AssaultWare.Controls;component/Replayer/Images/button_off.png" Visibility="Hidden"/>
        </Grid>
        <ControlTemplate.Triggers>
            ...
        </ControlTemplate.Triggers>
    </ControlTemplate>
</UserControl.Resources>

<Button Canvas.Left="471" Canvas.Top="465" Template="{StaticResource ActionButton}" Name="btnRight"/>
+2  A: 

Difficult to decipher your question, but I think you just need to change the Label to a ContentControl and bind its Content property to the Button's Content property:

<ContentControl Content="{TemplateBinding Content}" .../>

HTH,
Kent

Kent Boogaart
I may have made it difficult to decipher but you nailed it. Thank you sir
Ready Cent