tags:

views:

591

answers:

1

I am using a ImageButton as

            <Button Width="80" Height="25"
                    VerticalAlignment="Top" 
                    HorizontalAlignment="Right" 
                    HorizontalContentAlignment="Center"
                    VerticalContentAlignment="Center"
                    Margin="0,0,1.5,0"
                    Name="btnActivate"
                    Click="OnActivate">
                <StackPanel Orientation="Horizontal" Margin="3">
                    <Image Source="Shutdown.ico" 
                           Width="12" Height="12" 
                           Margin="0,0,5,0"/>
                    <TextBlock>Activate</TextBlock>
                </StackPanel>
            </Button>

I want to change the Content of button to 'Deactivate' when I click on it without changing the image. How can I do that? And also I need to some operations based on the content of button in my C# code.

+1  A: 

You could just add a name to the TextBlock

<TextBlock Name="textBlock1">Activate</TextBlock>

and use it to modify the content in your OnActivate event handler

textBlock1.Text = "Deactivate";
Oskar