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

  • Home
  • SEARCH
  • 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 7808221
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T03:04:56+00:00 2026-06-02T03:04:56+00:00

I want to set a Control on my GUI transparent through manipulating opacity value.

  • 0

I want to set a Control on my GUI transparent through manipulating opacity value.
Therefore, I initialize a BackgroundWorker on the constructor of my WPF-Form like :

volumeWorker = new BackgroundWorker();
volumeWorker.DoWork += new DoWorkEventHandler(VolumeBarDoWork);
volumeWorker.ProgressChanged += new ProgressChangedEventHandler(VolumeBarChanged);
volumeWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(VolumeBarCompleted);
volumeWorker.WorkerReportsProgress = true;

After that, my GUI waits for an event, which is triggered by another class

soundController = new SoundController();
soundController.VolumeChanged +=new SoundController.VolumeChangedEventHandler(VolumeChanged);

On the event handler i finally will start the volumeWorker (BGW) to manipulate the GUI:

private void VolumeChanged(float pVolume)
{
    Logger.InfoWrite("Event raised ## New volume : {0}", pVolume);
    volumeWorker.RunWorkerAsync();
}

But on BackgroundWorkers ChangeEvent, i got a InvalidOperationException every time.Did anyone got a idea?

private void VolumeBarDoWork(object sender, DoWorkEventArgs e)
{
    BackgroundWorker worker = sender as BackgroundWorker;
    Logger.InfoWrite("Worker");
    for(int _opacity = 99 ; _opacity >= 0 ; _opacity--)
    {
        Logger.InfoWrite("Start on {0}", _opacity);
        worker.ReportProgress(_opacity);
        System.Threading.Thread.Sleep(20)
    }
    e.Result = e.Argument;
}

private void VolumeBarChanged(object sender, ProgressChangedEventArgs e)
{
    this.volumeBar.Opacity -= 0.01f;
    Logger.InfoWrite("Changed opacity to : {0} on {1}", this.volumeBar.Opacity, e.ProgressPercentage);
}

private void VolumeBarCompleted(object sender, RunWorkerCompletedEventArgs e)
{
    Logger.InfoWrite("Completed");
    this.volumeBar.Opacity = 0.0f;
}
  • 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-06-02T03:04:57+00:00Added an answer on June 2, 2026 at 3:04 am

    You cannot change UI directly outside the UI thread, since the UI controls are created on the UI thread. Use the Dispatcher.Invoke or BeginInvoke method instead.

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

Sidebar

Related Questions

I want to set up inline content of a WPF WebBrowser control: <WebBrowser> <html>
Basically, in my application's initialization, I want to set the value of a control's
I have a wpf control and i want to set the name to contain
Using WPF, I have a TreeView control that I want to set its ItemTemplate
I have one control named thumbviewer inside repeater. I want to set its imageurl
How can I use variables to set my timer? I want to control delay
I want to loop through the controls on a UserControl and set a property
I want set Listbox background to transparent but not working Is there any idea?
I am running a Python GUI application. I want to invoke and control GDB
I want to set up source control for my project, but it seems like

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.