Welcome to Pete Brown's 10rem.net

First time here? If you are a developer or are interested in Microsoft tools and technology, please consider subscribing to the latest posts.

You may also be interested in my blog archives, the articles section, or some of my lab projects such as the C64 emulator written in Silverlight.

(hide this)

Fix to Inherit from Silverlight Sample Controls

Pete Brown - 10 June 2007

(I posted this in the Silverlight Programming with .NET forum)

FYI. I ran into this problem tonight, and thought I'd post the solution here.

I am using sample controls in the SDK. In my solution, I have kept the 1.1 SDK example in its own project, as it is shipped, and I reference it from my main project.

In the Silverlight SDK Controls examples, there is a class named ControlBase. In my main project, I have a button-type control that inherits from SDK ButtonBase which inherits from ControlBase.

The SDK ControlBase constructor tries to be clever about picking up the name of the xaml file that contains the markup for the derived control. Unfortunately, it is unable to check outside of its own assembly because it calls this code:

     Assembly assembly = typeof(ControlBase).Assembly;
     string[] names = assembly.GetManifestResourceNames();

which brings back only xaml files that are part of the SL Samples assembly.Changing that line to this fixes the problem:

     Assembly assembly = this.GetType().Assembly;
     string[] names = assembly.GetManifestResourceNames();

posted by Pete Brown on Sunday, June 10, 2007
filed under:  

Comment on this Post

Remember me

1 trackback for “Fix to Inherit from Silverlight Sample Controls”

  1. Fix for Extending Controls in SDK « Desperately Seeking Love of Sophiesays:
    PingBack from http://vivekdalvi.wordpress.com/2007/06/11/fix-for-extending-controls-in-sdk/