Experiments in Building a Silverlight Photo Control ( Part 4 )

Following on from this post, I wanted to see what would happen if I opened my solution in Expression Blend 2.5 June Preview and tried to style my control a little.

So, I opened it in Blend.

I got a bit stuck straight away because when I tried to display my page.xaml Blend threw up an error;

image

From the stack trace, this looked suspiciously like some of my code running to load images when it really shouldn’t be inside of a design time environment like Blend.

So, I added a little member function to my control;

    private bool IsInDesignMode
    {
      get
      {
        return (DesignerProperties.GetIsInDesignMode(this));
      }
    }

and called it from a few places to stop the control trying to load images and so on if it’s in design mode rather than run-time mode and Blend sprung into life;

image

Now…to try and set about styling the control. First off, I created an empty template for my control;

image

Then I took the Grid that’s given to me;

image

and replaced it with a StackPanel, some Buttons, an Image and a couple of other bits and pieces to create my UI. I made sure to name this things in accordance with the naming expected by my control. I managed to get as far as this;

image

Which gives me this delightful look and feel 😉

image

With a sort of “border path” that I “drew” in Expression Design but then I got stuck in that I get exceptions from Blend if I try and change the template on those buttons that I’ve got. That is, just picking one of those buttons and doing “Edit Empty Template” gives me;

image

I wasn’t entirely sure what to do about that but I found that if I went into the XAML and just set up a Template for the buttons manually and then just put something basic into that template then once I revisited that in Blend it would now edit that template.

So, I managed to get a fairly ugly looking thing 🙂 but at least it looks different from where I started;

image

And, with that, I’m giving up for a while 🙂

If you want the project, then I shared the whole thing here for download. It includes the web project, the images, everything so you should be able to just press F5. Most of the size of the ZIP file is the 5 images which are taken from Windows.