0

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 Answer 1

1

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";
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.