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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T21:52:33+00:00 2026-05-31T21:52:33+00:00

My question is simple: WHEN (on what event?) can I be sure that a

  • 0

My question is simple: WHEN (on what event?) can I be sure that a control has fully loaded and has its states and templates also?

Why am I asking:

I’m trying to restore the state of my own WP7 control after recovering from tombstone. This control looks like a calendar in a weekly view. In this calendar you can select many items displayed as colored Rectangles.

If I select any of them, and then go to tombstone and come back to the page, it seems like my control forgot which Rectangles were selected. In fact, it did NOT forget the data itself, but the Rectangles forgot their selected state.

After recovering from tombstone, I try to select the Rectangles by setting their VisualState to “Selected” (which works in any other scenario). I found out, that it fails, because VisualStateManager can’t find the "Selected" state.

I know this is tricky, because when coming back from tombstone the controls do not build exactly as in any “normal” case. (for example Bindings and Templates do not apply in the same order) But up until now I could always trust, that when FrameworkElement.Loaded fired, I had my controls ready. Now it seems like VisualState is not. (I tried to set the state from Loaded event handler, but results are the same, VisualStateManager.GoToState returns with false.)

What more can I do?

  • 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-31T21:52:34+00:00Added an answer on May 31, 2026 at 9:52 pm

    This is a tricky one! I have also experienced issues where UI events fire before the UI itself is fully constructed, see this blog post for an example. My general approach to this is to handle the LayoutUpdated event, which fires each time the visual tree is updated. You will find that this event fires multiple times, both before and after the Loaded event.

    When the Layoutupdated event fires, you can check whether the visual state change has worked, if so, no longer handle the event. If not, keep trying!

    Within your loaded event, try the following:

     // try to set the state
      if (VisualStateManager.GoToState(myControl, "myState") == false)
      {
        // if failed, wait for the next LayoutUpdated event
        EventHandler updateHandler = null;
        updateHandler = (s, e2) =>
        {
          if (VisualStateManager.GoToState(myControl, "myState") == false) 
          {
            myControl.LayoutUpdated -= updateHandler;
          }
        };
        myControl.LayoutUpdated += updateHandler;
      }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Simple question: How do I detect that the onscreen keyboard has been displayed on
A simple question I'm sure, but I can't figure it out. I have some
Simple question, but one that I've been curious about...is there a functional difference between
Simple question that keeps bugging me. Should I HTML encode user input right away
Pretty simple question: When i have a persistable object, it usually has a property
I'm fairly sure this is a template question, since I can't seem to solve
This is a silly simple question I’m sure, but since I’m new to Magento,
I'm trying to write a simple app that has several internal pages. From #page2
it is a very simple question that I'm not finding an answer for it.
Pretty simple question this time around. I have an application that communicates with another

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.