Saturday 21 June 2008

Silverlight 2.0 Beta 2 - Update on creating a user control to be used as a base class

It appears I was wrong in my previous post.

The ContentPropertyAttribute is seemingly ignored! Although it compiles, and can be edited in Blend, you get a XamlParseException when you try to run it:

"ShellBase does not support Grid as content"

The solution is to manually specify the content property in your Xaml (which kind of sucks!). Strange as this all used to work in Beta 1 (although there were other issues involving namespace parsing which have now been fixed). The correct Xaml looks like this:

<Silverstone:ShellBase x:Class="Silversocial.Client.Views.Shell"

   xmlns="http://schemas.microsoft.com/client/2007"

   xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

   xmlns:Silverstone="clr-namespace:Silverstone;assembly=Silverstone">

    <Silverstone:ShellBase.Content>

        <Grid Background="#FF000000">

 

        </Grid>

    </Silverstone:ShellBase.Content>

</Silverstone:ShellBase>

I think (hope) this may be a bug but I will try to confirm this and update my blog if I find out any more.

1 comment:

Anonymous said...

Check this out:

http://silverlight.net/forums/t/12327.aspx