VisualStateManager not working as advertised

190 views
Skip to first unread message

Kent Boogaart

unread,
Feb 15, 2011, 5:34:19 AM2/15/11
to WPF Disciples
All,

I just posted this question on StackOverflow (where I can format it
nicely): http://stackoverflow.com/questions/5002501/visualstatemanager-not-working-as-advertised

It really is a perplexing issue that has wasted me a lot of time over
the past week or so, due to its unpredictability and the odd ways it
can manifest itself in a more complicated project such as the one I've
been working on.

If you could take a look and see if you have any thoughts, I'd greatly
appreciate it. Feel free to post here or on SO - I'll make sure to
link all the information together for future reference.

Thanks,
Kent

Marlon Grech

unread,
Feb 16, 2011, 2:35:59 PM2/16/11
to wpf-di...@googlegroups.com
mmmm very strange ... sometimes VSM scares me... it does quite a bit of magic.... nice find with the fix i.e Duration=0

Regards
Marlon
WPF Blog - http://marlongrech.wordpress.com/
Microsoft MVP for Client App

Kent Boogaart

unread,
Feb 16, 2011, 4:21:53 PM2/16/11
to WPF Disciples
Yeah, I have a far less trusting relationship with VSM now.

To be clear, the "fix" involved Duration didn't actually fix anything.
I've not been able to find any workaround yet.

I reported it on Connect today:
https://connect.microsoft.com/VisualStudio/feedback/details/644453/erattic-behavior-in-visualstatemanager.
Any votes/confirmations of repro appreciated.

Hope all is well in Malta, Marlon.

Best,
Kent


On Feb 16, 7:35 pm, Marlon Grech <marlongr...@gmail.com> wrote:
> mmmm very strange ... sometimes VSM scares me... it does quite a bit of
> magic.... nice find with the fix i.e Duration=0
>
> Regards
> Marlon
> WPF Blog -http://marlongrech.wordpress.com/
> Microsoft MVP for Client App
>
> On Tue, Feb 15, 2011 at 11:34 AM, Kent Boogaart <kent.booga...@gmail.com>wrote:
>
> > All,
>
> > I just posted this question on StackOverflow (where I can format it
> > nicely):
> >http://stackoverflow.com/questions/5002501/visualstatemanager-not-wor...

Peter O'Hanlon

unread,
Feb 16, 2011, 4:29:29 PM2/16/11
to wpf-di...@googlegroups.com
This is why I prefer WPFs approach to triggers and animations. There's less sacrificing a chicken involved.
--
Peter O'Hanlon

Sacha Barber

unread,
Feb 17, 2011, 1:57:58 AM2/17/11
to wpf-di...@googlegroups.com
I agree with that too.
--
Sacha Barber
sacha....@gmail.com

Marlon Grech

unread,
Feb 17, 2011, 2:43:43 AM2/17/11
to wpf-di...@googlegroups.com
still VSM gives a big + to Developer Designer workflow... designers love VSM and I must admit I love the idea as well, its the implementation that i believe can be improved.,.. its not that its not good, its that there is a lot of stuff going on in the dark and you are not aware of it. Then there is also the fact that when it comes to control it lacks a bit ..

Regards
Marlon
WPF Blog - http://marlongrech.wordpress.com/

Microsoft MVP for Client App



Kent Boogaart

unread,
Feb 17, 2011, 2:59:20 AM2/17/11
to WPF Disciples
Agreed - I want to use it because of its promise to make my life
easier, and to make collaboration with a designer easier (I actually
have a "Blend guy" on my current project!). But it has wasted me so
much time, as you guys have probably noticed by my posts on this board
lately.

I was extra disappointed when I turned on animation tracing and
got . . . so very little. Nothing VSM-specific at all - just
storyboards starting stopping with no explanation as to why.

Kent

On Feb 17, 7:43 am, Marlon Grech <marlongr...@gmail.com> wrote:
> still VSM gives a big + to Developer Designer workflow... designers love VSM
> and I must admit I love the idea as well, its the implementation that
> i believe can be improved.,.. its not that its not good, its that there is a
> lot of stuff going on in the dark and you are not aware of it. Then there is
> also the fact that when it comes to control it lacks a bit ..
>
> Regards
> Marlon
> WPF Blog -http://marlongrech.wordpress.com/
> Microsoft MVP for Client App
>
> On Wed, Feb 16, 2011 at 10:29 PM, Peter O'Hanlon <pete.ohan...@gmail.com>wrote:
>
> > This is why I prefer WPFs approach to triggers and animations. There's less
> > sacrificing a chicken involved.
>
> > On 16 February 2011 21:21, Kent Boogaart <kent.booga...@gmail.com> wrote:
>
> >> Yeah, I have a far less trusting relationship with VSM now.
>
> >> To be clear, the "fix" involved Duration didn't actually fix anything.
> >> I've not been able to find any workaround yet.
>
> >> I reported it on Connect today:
>
> >>https://connect.microsoft.com/VisualStudio/feedback/details/644453/er...
> >> .

Kent Boogaart

unread,
Feb 17, 2011, 7:06:07 AM2/17/11
to WPF Disciples
Did some digging and found that this is due to the VSM depending on
the Storyboard.Completed event to be raised:

dynamicTransition.Completed += delegate
{
// when Completed is raised, everything works fine. But
Completed is not always raised!
};

So it seems this bug is as a result of another long-standing and
seemingly ignored bug on Connect:
https://connect.microsoft.com/VisualStudio/feedback/details/571102/storyboard-completed-event-is-not-raised-or-handled

This is madness! How can this *not* be affecting *everyone* doing any
animations with any complexity at all?

Am still digging to see whether I can concoct a workaround/hack, but
the odds don't look good. *sigh*

Kent
> > > Peter O'Hanlon- Hide quoted text -
>
> - Show quoted text -

Pavan Podila

unread,
Feb 17, 2011, 7:11:37 AM2/17/11
to wpf-di...@googlegroups.com
Kent,
        I have had problems in the past for storyboards not firing their completed events. What I have realized is that if you replace a Storyboard directly, without first stopping it, you may see some out-of-order Completed events. In my case I was applying newer Storyboards to the same FrameworkElement, without stopping the earlier Storyboard and that was giving me some issues. Not sure if your case is similar but thought I'll share this tidbit.


Pavan

Kent Boogaart

unread,
Feb 17, 2011, 7:51:03 AM2/17/11
to WPF Disciples
Pavan, I owe you a beer.

I replaced this line of the VisualStateManager class:

// storyboards are separate so are started independently
group.StartNewThenStopOld(element, transition.Storyboard,
dynamicTransition);

with this:

var masterStoryboard = new Storyboard();
masterStoryboard.Children.Add(transition.Storyboard);
masterStoryboard.Children.Add(dynamicTransition);

// storyboards have been combined into single parent storyboard
group.StartNewThenStopOld(element, masterStoryboard);

and it frigging works. Granted I need some error checking and further
thought around that code, but did I mention it frigging works!?

At least now I have a way forward. Looks like I'm fixing VSM and
depending on a custom build. Not sure how that's gonna fly in a big
corporate, but the alternative is unpredictable behavior in the
controls I've been developing.

Pavan, I'm going to update the StackOverflow post and Connect issue
with the details of this once I have it rounded out. I will credit you
with the inspiration, of course!

Cheers,
Kent

On Feb 17, 12:11 pm, Pavan Podila <pavan.pod...@gmail.com> wrote:
> Kent,
>         I have had problems in the past for storyboards not firing their
> completed events. What I have realized is that if you replace a Storyboard
> directly, without first stopping it, you may see some out-of-order Completed
> events. In my case I was applying newer Storyboards to the same
> FrameworkElement, without stopping the earlier Storyboard and that was
> giving me some issues. Not sure if your case is similar but thought I'll
> share this tidbit.
>
> Pavan
>
> On Thu, Feb 17, 2011 at 7:06 AM, Kent Boogaart <kent.booga...@gmail.com>wrote:
>
>
>
>
>
> > Did some digging and found that this is due to the VSM depending on
> > the Storyboard.Completed event to be raised:
>
> >    dynamicTransition.Completed += delegate
> >    {
> >        // when Completed is raised, everything works fine. But
> > Completed is not always raised!
> >    };
>
> > So it seems this bug is as a result of another long-standing and
> > seemingly ignored bug on Connect:
>
> >https://connect.microsoft.com/VisualStudio/feedback/details/571102/st...
> Dev<https://mvp.support.microsoft.com/profile/Pavan.Podila>
> Author of WPF Control Development
> Unleashed<http://www.amazon.com/WPF-Control-Development-Unleashed-Experiences/d...>
> --| Blog:http://blog.pixelingene.com|--- Hide quoted text -

Pavan Podila

unread,
Feb 17, 2011, 8:10:50 AM2/17/11
to wpf-di...@googlegroups.com
Cool, glad it's working out for you.

Pavan

-----------------------------------
Pavan Podila
http://blog.pixelingene.com

Marlon Grech

unread,
Feb 17, 2011, 8:31:19 AM2/17/11
to wpf-di...@googlegroups.com
very cool !!!! 

Regards
Marlon
WPF Blog - http://marlongrech.wordpress.com/

Microsoft MVP for Client App



Mark Smith

unread,
Apr 6, 2011, 3:06:37 PM4/6/11
to wpf-di...@googlegroups.com
I know XBAP isn't the trendy cool kid on the block, but I hadn't realized MS had deprecated it's support for Firefox -- from http://msdn.microsoft.com/en-us/library/cc716877.aspx

The WPF plug-in for Firefox enables XBAPs and loose XAML files to be navigated to and run at the top-level or in an HTML IFRAME in the Firefox browser. An XBAP is a WPF application that can be published to a Web server and launched within supported browsers. Loose XAML is a XAML-only file that can be navigated to and displayed in supported browsers, much like an XML file.
The WPF plug-in for Firefox is installed with the .NET Framework 3.5. Window 7 includes the .NET Framework 3.5, but does not include the WPF plug-in for Firefox. You cannot install the WPF plug-in for Firefox on Windows 7.
The .NET Framework 4 does not include the WPF plug-in for Firefox. However, if both the .NET Framework 3.5 and .NET Framework 4 are installed, the WPF plug-in for Firefox is installed with the .NET Framework 3.5. Therefore .NET Framework 4 applications will still run because the WPF Host will load the correct version of the framework.

---

Anyone know why this was done?  And is this actually accurate?

Peter O'Hanlon

unread,
Apr 6, 2011, 3:10:42 PM4/6/11
to wpf-di...@googlegroups.com
It's the slow steady death of WPF. It was good while it lasted, but it looks like the affair is over. The new girl in town is HTML 5, and she's getting all the looks. WPF is packed off like a putrid old hag (just witness the lack of anything WPFy at Mix this year - she's old news).
--
Peter O'Hanlon

Mark Smith

unread,
Apr 6, 2011, 3:16:50 PM4/6/11
to wpf-di...@googlegroups.com
Yeah, I get that it's a finished product and there are newer, bright, shiny things to look at now - but you generally don't expect to remove working features - isn't it now in "maintenance" mode?  MFC is still getting updated to track with Windows 7 and it was passed over long ago.  Sigh.

mark

Pete Brown

unread,
Apr 6, 2011, 4:34:13 PM4/6/11
to wpf-di...@googlegroups.com

The XBAP model isn’t really suited for public web applications: both Silverlight and HTML offer better choices there for most applications. When doing a web crawl of the public internet, I don’t believe we found a single xbap in the wild. I do recall seeing demos of one or two in the past, but those were for in-store apps that ran behind a firewall.

 

In IE9, xbap support is turned off by default in the internet zone, and prompts (I believe) in the intranet zone. Most firefox users either didn’t care to use xbaps, or simply turned off that support themselves.

 

This has nothing to do with the “death of WPF” and everything to do with realizing that for most applications, there are far better models than xbap. When i was a consultant, I stopped considering xbap once Silverlight came out. I now recommend Silverlight, Click Once WPF apps, or even that other popular web technology used for dancing hamsters and whatnot ;)

 

WPF is an awesome client app technology. I don’t really think it belongs in the browser, IMHO.

 

Pete

 

Pete Brown - Developer Division Community Program Manager - Windows Client

twitter: @pete_brown |blog/site: http://10rem.net

Silverlight 4 in Action – Now available!

Description: Silverlight4InAction

 

Peter O'Hanlon

unread,
Apr 6, 2011, 4:38:15 PM4/6/11
to wpf-di...@googlegroups.com
Oh I agree, but it was fun to yank your chain. I can't think of a single time when I even considered using an XBap - ClickOnce would be my first thought in situations that might have prompted it.
--
Peter O'Hanlon
image001.png

Pete Brown

unread,
Apr 6, 2011, 4:53:26 PM4/6/11
to wpf-di...@googlegroups.com

I actually personally killed Xbap, because I wanted to sell more copies of my book ;)

 

Pete Brown - Developer Division Community Program Manager - Windows Client

twitter: @pete_brown |blog/site: http://10rem.net

Silverlight 4 in Action – Now available!

Description: Silverlight4InAction

 

 

From: wpf-di...@googlegroups.com [mailto:wpf-di...@googlegroups.com] On Behalf Of Peter O'Hanlon
Sent: Wednesday, April 06, 2011 4:38 PM
To: wpf-di...@googlegroups.com
Subject: Re: [WPF Disciples] XBAP

 

Oh I agree, but it was fun to yank your chain. I can't think of a single time when I even considered using an XBap - ClickOnce would be my first thought in situations that might have prompted it.

Peter O'Hanlon

unread,
Apr 6, 2011, 4:54:37 PM4/6/11
to wpf-di...@googlegroups.com
Double tap?
--
Peter O'Hanlon
image001.png

Mark Smith

unread,
Apr 6, 2011, 6:11:22 PM4/6/11
to wpf-di...@googlegroups.com
Thanks Pete- I have a client that actually does use it for an intranet application -- they needed 3D in the browser (as part of a portal site).  They hadn't complained about Firefox - someone else pointed it out to me, so I was curious when that decision had been made.  I thought it odd that the plug in wasn't being maintained.

m

On Apr 6, 2011, at 1:34 PM, Pete Brown wrote:

The XBAP model isn’t really suited for public web applications: both Silverlight and HTML offer better choices there for most applications. When doing a web crawl of the public internet, I don’t believe we found a single xbap in the wild. I do recall seeing demos of one or two in the past, but those were for in-store apps that ran behind a firewall.
 
In IE9, xbap support is turned off by default in the internet zone, and prompts (I believe) in the intranet zone. Most firefox users either didn’t care to use xbaps, or simply turned off that support themselves.
 
This has nothing to do with the “death of WPF” and everything to do with realizing that for most applications, there are far better models than xbap. When i was a consultant, I stopped considering xbap once Silverlight came out. I now recommend Silverlight, Click Once WPF apps, or even that other popular web technology used for dancing hamsters and whatnot ;)
 
WPF is an awesome client app technology. I don’t really think it belongs in the browser, IMHO.
 
Pete
 
Pete Brown - Developer Division Community Program Manager - Windows Client
twitter: @pete_brown |blog/site: http://10rem.net
Silverlight 4 in Action – Now available!

Laurent Bugnion

unread,
Apr 6, 2011, 6:12:24 PM4/6/11
to wpf-di...@googlegroups.com

FWIW the large WPF project I was working on at Siemens was planning (and I believe still is) on using XBAPs as an alternate mode of deployment for some specific users. The joke about dancing hamsters, in that context, is not very funny considering that some guarantees have been offered by Microsoft at the time. Like Mark said, not adding features is a thing, but removing features is another. Of course Siemens is only the biggest global ISV for .NET… Good luck explaining that move to them though.

 

I really hope that it was removed for Firefox, but will remain available on IE. That is still going to be a pain to explain to the end users, but at least there is a workaround.

 

Good night,

Laurent

image001.png

Pete Brown

unread,
Apr 6, 2011, 6:38:29 PM4/6/11
to wpf-di...@googlegroups.com

Can you tell me more about why an xbap would work for users, but clickonce would not?

 

I’m not familiar with the guarantees. However, Xbap support is still there in IE, and works fine in intranet scenarios as I understand it (I haven’t tried it myself). I did mention that below, I’m not sure how you missed it. It’s in IE9, it hasn’t been pulled. It’s just not a good model for the internet.

 

I still think dancing hamsters are funny, but that may be just me ;)

Shawn Wildermuth

unread,
Apr 6, 2011, 6:40:53 PM4/6/11
to wpf-di...@googlegroups.com

Isn’t it likely not a removal of the feature, but a lot effort to keep up with changes in the dev model for FF?  I have no idea, but assuming it was a decision to just remove it seems unlikely.

 

Thanks,

Shawn Wildermuth

http://wildermuth.com

 

Note: This was typed on a big ole laptop so any misspellings and punctuations are completely my fault…not my phone’s.

image001.png

Pete Brown

unread,
Apr 6, 2011, 6:42:05 PM4/6/11
to wpf-di...@googlegroups.com

Again, intranet is probably fine. I’d consider moving it to Silverlight if you get the opportunity, but that’s not based on any internal roadmap knowledge for xbap.

 

Pete

 

Pete Brown - Developer Division Community Program Manager - Windows Client

twitter: @pete_brown |blog/site: http://10rem.net

Silverlight 4 in Action – Now available!

Description: Silverlight4InAction

 

Pete Brown

unread,
Apr 6, 2011, 6:47:48 PM4/6/11
to wpf-di...@googlegroups.com

As an aside, community members have said to us time and again that we should deprecate and/or remove WPF features that just didn’t pan out one way or another, or are duplicated in the same or another technology, to reduce the size of the framework and the complexity of learning WPF.

 

Now you see why that’s difficult to do. There is always *someone* who relied on a feature for some app somewhere. J

 

Pete

 

Pete Brown - Developer Division Community Program Manager - Windows Client

twitter: @pete_brown |blog/site: http://10rem.net

Silverlight 4 in Action – Now available!

Description: Silverlight4InAction

 

 

From: wpf-di...@googlegroups.com [mailto:wpf-di...@googlegroups.com] On Behalf Of Pete Brown
Sent: Wednesday, April 06, 2011 6:42 PM
To: wpf-di...@googlegroups.com
Subject: RE: [WPF Disciples] XBAP

 

Again, intranet is probably fine. I’d consider moving it to Silverlight if you get the opportunity, but that’s not based on any internal roadmap knowledge for xbap.

Reply all
Reply to author
Forward
0 new messages