Showing posts with label visual studio. Show all posts
Showing posts with label visual studio. Show all posts

Wednesday, December 15, 2010

WPF VisualStateManager GotoState Bug

So, I just wasted a couple of hours trying to figure this one out so I thought I’d post about it so you guys don’t have to waste as much time as I did on it.

The WPF VisualStateManager implementation is still not as rock solid as Silverlight’s implementation (ok, let’s face it, Silverlight’s implementation is far from rock solid too, but it is much better of at this point). If you are trying to call the VisualStateManager.GotoState Method on a Window, you are going to be very very frustrated. Why? Because it doesn’t work. If you are inside a user control, it is fine, but inside of a Window… nope!

Instead of calling this

VisualStateManager.GoToState(this, "stateName", true);


You are going to need to call this



VisualStateManager.GoToElementState(this.RootElement as FrameworkElement, "stateName", true);


That should do it for you. Microsoft is aware of the issue and has promised to fix this, but who knows when that’s going to happen.



Happy state-changing!



 




Friday, February 6, 2009

Help! My breakpoints are not being hit!

Man! I have wasted a lot of time the past two days with this one, so I thought I would blog about it immediately in case anyone else is seeing this. As I was working on a Silverlight app, I ran into a bug. I decided to add a breakpoint and run the debugger in order to see what was going on. I added the breakpoint and ran the debugger (F5). I noticed the red circle that indicates the breakpoint changed from a red circle to a little warning sign with an error message. "The breakpoint will not currently be hit. No symbols have been loaded for this document."

image

This started me off on an incredibly painful, and long search for answers. I tried deleting every possible temporary file I could think of. I tried cleaning the solution and rebuilding it. I restarted Visual Studio. I ran IISReset. I rebooted my machine. I tried a handful of other things and... nothing! I was still not able to debug! Finally, one of my co-workers saw a post on that said to check the properties of the web project you are trying to debug (right click on it in the solution explorer). Next click on the Web tab and make sure that Silverlight is selected as one of the Debugger options.

image

Some way or another, the Silverlight option became unchecked. Once I checked it, I was able to run and debug with no problems. I hope this saves some of you a lot of headaches and hours of wasted time.

Good find on this one Scott!