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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T12:15:04+00:00 2026-06-18T12:15:04+00:00

I’m working on a state machine program with wpf as UI layer, I used

  • 0

I’m working on a state machine program with wpf as UI layer, I used this link:
http://elijahm.ninjuro.com/2012/01/04/visual-states-in-wpf-4-0/#comment-312 article to change contents of active window by calling VisualStateManager.GoToState(,,).

but I’m not a good wpf developer and my problem is the last section of that article, section “Changing from one state to another” in where developer creates StateManager class and use it to change UI state.
I don’t know where in my code I mast use of StateManager and how to transmit business state changes to UI?

  • 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-18T12:15:05+00:00Added an answer on June 18, 2026 at 12:15 pm

    Good question. It looks like the author of that blog post does assume that you’ll know where to put the code pieces that he shows, based partially on the names of classes and the use of bindings, etc. Also, if you haven’t already, it will help to read up on the MVVM pattern so that the things that he references will make better sense.

    Having said that, I’ll provide a brief explanation of that section of the blog post. First, that “StateManager” class is analogous to the “StateHelper” class in this answer. That answer has a bit more explanation as well.

    Essentially, we have three main pieces that we need to work together: The ViewModel, the View, and a custom attached property class (especially the changed callback method for this attached property).

    The author created a property in his ViewModel (of type string) called “ViewState”. The idea here is that, in his methodology at least, the ViewModel will know when a view state should be changed (i.e., in reaction to a certain change in data). So when that time comes, he will change the ViewModel’s “ViewState” property to another state name (maybe “alertState” or something), using regular C# code – maybe something like:

    this.ViewState = "alertState";  
    

    The thing that then ties this together is the fact that the View has a way of just binding (i.e., “listening to changes to”) to those “state changes” – meaning that the view executes the state changes by listening to changes to the “ViewState” property of the ViewModel (not quite that simple, but I’ll get there in a minute).

    StateManager.VisualStateProperty = "{Binding Path=ViewState}"
    

    And the way that it is able to execute the actual VisualStateManager state change is that the custom “StateManager.VisualStateProperty” attached property’s changed callback method executes the built-in WPF method VisualStateManager.GoToState(...). In his post, this is the changed callback that I’m referrring to:

    new PropertyMetadata((dependencyObject, args) =>
    {
        var frameworkElement = dependencyObject as FrameworkElement;
        if (frameworkElement == null)
            return;
        VisualStateManager.GoToState(frameworkElement, (string)args.NewValue, true);
    }));
    

    So when the ViewModel changes its ViewState property, and since the View has a binding to that property, and since this custom attached property has been assigned the result of that binding, the binding engine changes the “result” of its binding, which causes the value of “StateManager.VisualStateProperty” to change, which causes the above changed callback method to fire, which (finally) causes the VisualStateManager.GoToState(..) method to execute the actual Visual State change.

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

Sidebar

Related Questions

I'm not entirely sure how I managed to jack this up. http://pretty-senshi.com If you
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
For some reason, after submitting a string like this Jack’s Spindle from a text
I used javascript for loading a picture on my website depending on which small
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString

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.