views:

369

answers:

1

I want to be able to store various Canvas items in seperate XAML files so for example they are declared as:

<canvas x:Class="Item.One" Height="300" Width="400">
...
</canvas>

and another like this

<canvas x:Class="Item.Two" Height="300" Width="400">
...
</canvas>

I am wondering why I cannot get this to work when I try and load them in as classes I get a parser error, I can do this fine in WPF but not in Silverlight 3.0, what can you do to have to have XAML work as objects rather than resources?


Just to help the Parser error is

AG_E_PARSER_BAD_TYPE

And a real example that does not work:

<Canvas x:Class="Cards.Appointment.ZuneVertical" x:Name="ZuneVertical"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Width="240" Height="320" Background="White">
</Canvas>


In my code I want to do this:

Preview.Children.Add(Item.One)

Where Preview is a Grid within a ScrollView which is where I want the XAML to be loaded into, ie the Canvas, there a various versions of Canvas I want to load into this Preview Pane, each one is a Class as XAML in WPF, but cannot seem to get this to work in Silverlight 3.0 without the parsing error, tried UserControls but this has the same problem!

+1  A: 

Seems it was a problem with the Namespace of my XAML file I added the Application Namespace and this resolves the problem.

<Canvas x:Class="ZuneCardrintouch.Cards.Appointment.ZuneVertical" />
RoguePlanetoid