views:

1076

answers:

2

I'm building custom control for my Silverlight 2 app. It's in one SL class project, and it contains two files:

  • MyControl class, inherited from Control, with few DepedencyProperties
  • themes/generic.xaml, with visual elements (ControlTemplate), states for VSM and transitions

I created whole xaml by hand, and it works, but want to use Blend2(SP1) for editing! When i open generic.xaml in Blend, and switch to Resources tab I don't have anything to edit.
For example, when I put that visual template and states definition to App.xaml (of my main SL project), I can access all elements and States through Resources and States tabs, and edit them visually.

Does Blend even support editing generic.xaml from SL2 class project?
What's the best practice for building custom controls? I don't want to my custom control depends on anything from main SL2 project, but want them to be skinnable, and be able to change skins (themes) dynamically.

+4  A: 

You can edit this with Blend.

  1. Open your controls project in Blend.
  2. Open your generic.xaml
  3. click the Resources tab
  4. Expand generic.xaml
  5. Double click the style resource you want to edit.
  6. In the Objects and Timeline section, right click the Style and select "Edit Control Parts -> Edit Template"

Now you can edit the template in the generic.xaml. Sounds like you're already following best practices by having the parts and states. If you want the full blown best practices take a look at this detailed post on how to deal with design time extensibility. There you will find out how to do the Visual Studio and Blend design time stuff for Silverlight.

Bryant
I tried that, but there's nothing in Resource tab, like i have written in my question
Hrvoje
A: 

I recreated whole project, and suddenly can edit my generic.xaml from Resources. But can't add news stated in Blend, for that I must go to xaml.

Hrvoje