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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T13:40:23+00:00 2026-05-11T13:40:23+00:00

In my program I have three distinct UI states (Normal, Success, and Error) and

  • 0

In my program I have three distinct UI states (Normal, Success, and Error) and in each one the controls are visible/hidden, enabled/disabled, the colors change, labels say different things…etc. and in my code-behind I basically want to be able to say ChangeWindowState(UI.Normal);

So my question is how best to implement the control changes for each state?

Of course I could manually change the controls in the code-behind, but I wonder if maybe there is a better way by using wpf themes or styles. Then maybe I could just set the window to use the ‘Error’ theme, which I have pre-defined. I don’t really understand them at the moment so I may be using the terminology wrong, but I would appreciate if someone could point me in the right direction how best to do something like this.

Thanks!

  • 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. 2026-05-11T13:40:24+00:00Added an answer on May 11, 2026 at 1:40 pm

    There are many ways to approach this, of course. If you had a program-state ‘object model’ you could use some combination of DataTemplates and DataTriggers. Assuming this is not the case, here’s another approach: You referred to a window, so suppose you define a ‘dependency property’ in your window class like this:

    public partial class Window1 : Window {     public Window1()     {         this.InitializeComponent();          // Insert code required on object creation below this point.     }      public ProgramStatus ProgramStatus     {         get { return (ProgramStatus)GetValue(ProgramStatusProperty); }         set { SetValue(ProgramStatusProperty, value); }     }      // Using a DependencyProperty as the backing store for ProgramStatus.  This enables animation, styling, binding, etc...     public static readonly DependencyProperty ProgramStatusProperty =         DependencyProperty.Register('ProgramStatus', typeof(ProgramStatus), typeof(Window1), new UIPropertyMetadata(null)); }  public enum ProgramStatus {     Normal,     Success,     Error } 

    Now you can change pretty much any property of any element of the window (including the window itself), by either direct binding or a trigger. Here’s an example of changing the window’s background color via a property trigger:

    <Window     xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation'     xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'     xmlns:l='clr-namespace:Test'     x:Class='Test.Window1'     x:Name='Window'     Title='Window1'     Width='640' Height='480'>     <Window.Style>         <Style TargetType='{x:Type l:Window1}'>             <Style.Triggers>                 <Trigger Property='ProgramStatus'>                     <Trigger.Value>                         <l:ProgramStatus>Error</l:ProgramStatus>                     </Trigger.Value>                     <Setter Property='Background' Value='Red' />                 </Trigger>                 <Trigger Property='ProgramStatus'>                     <Trigger.Value>                         <l:ProgramStatus>Normal</l:ProgramStatus>                     </Trigger.Value>                     <Setter Property='Background' Value='Blue' />                 </Trigger>                 <Trigger Property='ProgramStatus'>                     <Trigger.Value>                         <l:ProgramStatus>Success</l:ProgramStatus>                     </Trigger.Value>                     <Setter Property='Background' Value='Green' />                 </Trigger>             </Style.Triggers>         </Style>     </Window.Style>     <Grid x:Name='LayoutRoot'/> </Window> 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 283k
  • Answers 283k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Ext.TitleCheckbox is not a function, you cannot make a function… May 13, 2026 at 4:12 pm
  • Editorial Team
    Editorial Team added an answer I found a way to do this. You can load… May 13, 2026 at 4:12 pm
  • Editorial Team
    Editorial Team added an answer No you don't - you can do: Person found =… May 13, 2026 at 4:12 pm

Related Questions

I'm running into a problem when trying to select records from my 2005 MS-SQL
I'm reading a algorithm book in my lesure time. Here is a question I
I use Visual Studio 2008 primarily for web development, and there's one annoying behaviour
i made a state machine and would like it to take advantage of generics

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.