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 8099709
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T22:29:58+00:00 2026-06-05T22:29:58+00:00

I have an event fired when some button is being clicked private void set_Opacity(object

  • 0

I have an event fired when some button is being clicked

private void set_Opacity(object sender, RoutedEventArgs e)
    {
        this.Opacity = 0;
    }

But there’s no effect when the button is clicked. What am I doing wrong?
Thanks.

EDIT :
I’ll give some background about what I am trying to do:

I have created a customized button that should minimize my window with a fade out animation so here’s the code of it:

 private void minimize_Window(object sender, EventArgs e)
    {
        var anim = new DoubleAnimation(0, (Duration)TimeSpan.FromSeconds(1));
        anim.Completed += (s, _) => this.Minimize();
        this.BeginAnimation(UIElement.OpacityProperty, anim);



    }
    private void Minimize()
    {
        WindowState = WindowState.Minimized;
    }

It works perfectly fine, though the problem is that when I try to retrieve my program from the task bar it won’t do anything (I am not able to see the program when I click on it from the taskbar after it minimized). What I understand from it is that the opacity of my program is being set to 0 while it got minimized(because of the animation).
So I used the Activated event calling that method:

private void set_Opacity(object sender, EventArgs e)
    {
        rectangle2.Opacity = 1;
        WindowState = WindowState.Normal;
    }

And still, same issue. Hope you could help.

Thank you very much.

  • 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-05T22:30:00+00:00Added an answer on June 5, 2026 at 10:30 pm

    The problem seems to be that in most cases, this is going to be a Window. My assumption though, is that you are not trying to set the entire window to invisible, rather a Rectangle. You need to give your Rectangle a name using x:Name attribute. Here is an example:

    <Rectangle Width="40" Height="40" x:Name="MyRectangle" Fill="Red" />
    

    Then, in your button click:

    private void set_Opacity(object sender, RoutedEventArgs e)
    {
        MyRectangle.Opacity = 0;
    }
    

    If you really are trying to set the entire Window‘s transparency:

    An entire Window can’t have it’s opacity set unless you specify AllowTransparency to true and WindowStyle to None in your XAML:

    <Window x:Class="ScratchApplication.MainWindow"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            AllowsTransparency="true" WindowStyle="None">
    

    Note the attributes being set.

    EDIT:

    I need an event to be fired when my program is being activated back from my task bar. Do you have any idea what event I could use?

    Use the Window.Activated event. From your XAML:

    <Window Activated="Window_Activated">
    

    And in your C#:

    private void Window_Activated(object sender, EventArgs e)
    {
        //Put code here
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have text input element and an event is fired on blur event and
I have a div positioning working which gets fired by the scroll-event. What happens
I have button, which fires an event, that deletes a record from the database.
I have a code like this where I am trying to add an event
I need to add onclick event to some dynamically added button , but when
CSS3 using Webkit in Safari; I have a button that, when clicked, causes a
If have an event that fires when a user clicks outside of text field,
I have an autocomplete event that fires correctly once a value is selected. I
I'm trying to have a jQuery UI event fire only if it meets the
I have an event, which can fire itself. I try to make the code

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.