 |
|
 |
|
|
|
Blend Artboard Exceptions and Loaded Event |
|
Andy's Blog
|
By Andy Beaulieu on
6/3/2009 8:35 AM
|
|
|
|
It can be frustrating when you are coding along in Silverlight, and you open up a UserControl in Blend only to see something like the following:
 An Exception was thrown. InvalidOperationException: HtmlPage_NotEnabled StackTrace InnerException: None
This is often caused by a UserControl that has a Loaded event with some code that isn't happy inside Blend's artboard. That's right - when you preview a UserControl inside Blend, the Loaded event for the control actually fires, and code in that handler is executed! You may have noticed this when you place a StoryBoard.Begin() call in the Loaded event, Blend will actually show the animation on the artboard.
So how do we workaround these exceptions? First, expand the StackTrace arrow, and you'll get some more details. In this case, we can see that the Loaded event for a UserControl named "ucResults" is the culprit:

Now that we know which Loaded event is causing the issue, take a look at the code and see what is going on. In this case, the code is accessing the HtmlPage class - which would not be available to Blend when it hosts the control on the artboard:
private void UserControl_Loaded(object sender, RoutedEventArgs e)
{
// Did the QueryString contain an Email address?
if (HtmlPage.Document.QueryString.Keys.Contains("Email") )
txtEmailTo.Text = HtmlPage.Document.QueryString["Email"].ToString();
}
Luckily, there is a special class, System.ComponentModel.DesignerProperties, which allows us to check at runtime whether we are in Design Mode or not. We can just add a check on this, and if we are in Design Mode, we get out of the Loaded event handler:
private void UserControl_Loaded(object sender, RoutedEventArgs e)
{
if (DesignerProperties.GetIsInDesignMode(this))
return;
// Did the QueryString contain an Email address?
if (HtmlPage.Document.QueryString.Keys.Contains("Email") )
txtEmailTo.Text = HtmlPage.Document.QueryString["Email"].ToString();
}
|
 |
|
Comments (1)
|
|
|
|
|
|
Upcoming Silverlight Talks |
|
Andy's Blog
|
By Andy Beaulieu on
5/7/2009 11:00 AM
|
|
|
|
I have a Silverlight Seminar and a webcast coming up at the end of May -if you're available then come and check them out!
GeekSpeak on Silverlight Game Development Wednesday, May 27th 2009 3pm EST The geekSpeak webcast series brings you industry experts in a "talk-radio" format hosted by developer evangelists from Microsoft. These experts share their knowledge and experience about a particular developer technology and are ready to answer your questions in real time during the webcast. To ask a question in advance of the live webcast, or for post-show resources, be sure to visit the geekSpeak blog.
Silverlight Seminar, presented by ACM Saturday, May 30th 2009 8:30am - 4:30pm EST Horizons Computer Learning Center, 6711 Towpath Rd., Suite 100, East Syracuse, NY This will be an all-day Introduction to Silverlight, with Hands-on-Labs.
|
 |
|
Comments (2)
|
|
|
|
SilverArcade Opens its Doors! |
|
Andy's Blog
|
By Andy Beaulieu on
4/20/2009 7:07 PM
|
|
|
|
SilverArcade is now live! This "free online game community" offers Silverlight-based diversions for the casual gamer, and per-play revenue for the Silverlight game developer. SilverArcade is the brainchild of Bill Reiss, Rob Eisenberg, and Chris Bennage.

It's great to see Silverlight coming into its own, seemingly with video and casual gaming leading the way (and with LOB apps closing the gap for the lead?!)
|
 |
|
Comments (0)
|
|
|
|
Boss Launch... LAUNCHED |
|
Andy's Blog
|
By Andy Beaulieu on
4/4/2009 8:22 PM
|
|
|
|
I had some time to update Boss Launch with a few fixes, a couple more levels, and some sound effects and loops. There are now five environments: Office, Forest, Desert, Beach and Moon! I also added a neat little "poke" functionality that allows you to move the Boss Ragdoll around by clicking him with the mouse after he is launched. This is really handy for knocking those closeby targets to the ground! I have a busy few weeks ahead, so this is probably how Boss Launch will stay for the next little while.
Go and have some fun!





|
 |
|
Comments (3)
|
|
|
|
Whats New in Silverlight 3 Graphics: Slides + Demos |
|
Andy's Blog
|
By Andy Beaulieu on
3/29/2009 10:46 AM
|
|
|
|
Thanks to everyone who attended my Silverlight Sessions at Code Camp 11! Chris Bowen and Chris Pels did another great job organizing what is the best free developer community event in the Northeast!
As promised, here are the slides and resources from the Silverlight 3 Graphics talk:
- What's New in Silverlight 3 Graphics
Up Next: Cre8 Conference
I'm excited to be presenting at the upcoming Cre8 Conference in Orlando, FL on April 15-16th! Cre8 is a conference for creative professional and covers the gamut of designer tools - everything from Flash, Dreamweaver, Photoshop... and yes, Silverlight. I'll be presenting:
Silverlight for Designers: Bridging the Gap from Designer to Developer Discover how to create an effective workflow that allows designers and developers to collaborate on interactive projects. Build easy-to-use interfaces that connect simply to Web services (the ‘cloud’), databases, XML content, and more.
|
 |
|
Comments (2)
|
|
|
|
|
Behaviors in Expression Blend 3 |
|
Andy's Blog
|
By Andy Beaulieu on
3/24/2009 3:49 PM
|
|
|
|
One of the really fun and productive things coming to Expression Blend 3 and Silverlight 3 is the concept of Behaviors. In a nutshell, you will be able to drag/drop a Behavior in Blend 3 onto a UI Element on the design surface, and that will automatically inject runtime logic into that element. Behaviors aren’t a new concept, and there is even an equivalent in the ASP.NET AJAX world if you’ve played with creating custom controls in that universe.
Physics Behaviors!
One of the most fun examples I’ve seen using Behaviors was done by Pete Blois, a Program Manager on the Expression team at Microsoft. Pete and another developer created some Physics Behaviors which very closely mirror the Physics Helper Library I created for the Farseer Physics Engine. I first saw Pete demo the Physics Behaviors at the MVP Summit a few weeks ago, and my jaw dropped at the similarities! Pete & Co.’s Physics Behaviors use the Box2D Physics Engine.
Getting Started with Behaviors
If you’re playing with Silverlight 3 and Blend 3, why wait? You can play with Behaviors today! Note this is all Beta level stuff, so be prepared for some hiccups along the way
Pete’s MIX Session – Pete Blois gave a great overview of Behaviors in this MIX 09 session.
Using Behaviors – A quick Walkthrough by Kirupa on how to use behaviors! Pay special attention to where you find the assembly Microsoft.Expression.Interactivity.dll - you'll need that for the next link.
MIX Behavior Pack – this contains the Physics Behaviors, as well as a bunch of others.
Creating New Behaviors
It turns out it’s pretty easy to create your own behaviors, and I’ll be covering this in a later blog post. But if you can’t wait, just download the MIX Behavior Pack and have a look at the Behaviors, all of their source code is included!
|
 |
|
Comments (1)
|
|
|
|
|
 |
|
 |
|
|