Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4617678
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T02:09:30+00:00 2026-05-22T02:09:30+00:00

I currently have a button, which has an icon/image on it. I have configured

  • 0

I currently have a button, which has an icon/image on it. I have configured the button and image in XAML:

<Button Height="69" HorizontalAlignment="Left" Margin="-2,0,0,0" Name="toggleBroadcast" VerticalAlignment="Top" Width="64" Grid.Row="1" Opacity="0.5" Click="changeBroadcastState_Click">
        <Image Source="Images\playIcon.png" />
</Button>

I need to be able to programmatically change this button’s image from playIcon to stopIcon. How can I do this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T02:09:30+00:00Added an answer on May 22, 2026 at 2:09 am

    You can accomplish this by changing the content of the button, through an event handler.

    You can set both the “Play” Icon and “Stop” Icon as a resource, under Window.Resources like so:

    <Window x:Class="WpfApplication1.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525">
    <Window.Resources>
        <Image x:Key="Play" Source="/WpfApplication1;component/Play_Icon.png" Height="50" Width="50" />
        <Image x:Key="Stop" Source="/WpfApplication1;component/Stop_Icon.png" Height="50" Width="50"/>
    </Window.Resources>
    <Grid>
        <Button Click="Button_Click" Name="MediaButton">
            <DynamicResource ResourceKey="Play"/>
        </Button>
    </Grid>
    

    Now, when the button is clicked, you can simply change the button’s content to a different resource (the stop icon). In the button’s event handler, you can do this:

    C#

    private void Button_Click(object sender, RoutedEventArgs e)
    {
        if (MediaButton.Content == FindResource("Play"))
        {
            MediaButton.Content = FindResource("Stop");
        }
        else
        {
            MediaButton.Content = FindResource("Play");
        }
    }
    

    Edit: Shorter notation

    MediaButton.Content = FindResource(MediaButton.Content == FindResource("Play") ? "Stop" : "Play");
    

    Hope this helps, let me know if you have any more questions.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a page of search results, each of which has an icon to
I have some JavaScript code and a button which already has an event/action assigned
I have a small iPhone app which has a button on the first view.
I have a asp radio button list which has 3 options: Option 1 Option
Hey guys, I currently have a root table view which has a toolbar at
I currently have a html login page which has two textfields for e-mail address
I currently have a simple form that when you click the save button will
I currently have my code set to disable the submit button when the field
Currently, I have some basic code to play a simple tone whenever a button
I have an Ajaxable application which has some UpdateProgress for each postBack events. everything

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.