This issue keeps coming up...
When VS gives you a message like this:
The element 'Page' in namespace 'http://schemas.microsoft.com/winfx/avalon/2005' has invalid child element 'Page.CommandBindings' in namespace 'http://schemas.microsoft.com/winfx/avalon/2005'. Expected 'Page.Resources, Page.StatusBarContent, Page.Storyboards, Page.Opacity, Page.Clip, Page.RenderTransform, Page.DataContext' in namespace 'http://schemas.microsoft.com/winfx/avalon/2005' as well as any element in namespace 'http://schemas.microsoft.com/winfx/xaml/2005' as well as …
It is likely a warning, not an error. The xml editor is warning that the xaml doesn't match the schema that we've provided for Avalon/Xaml.
Back in February, I blogged about the Issues/Suggestions for November Avalon CTP's VS2005 Add-ons ('Fidalgo'). I've updated the relevant section and included it here:
Avalon + XAML Schema Files
The XML Editor in Visual Studio uses XSD schema files to provide Intellisense support for many XML formats. If you are editing an xml format and want a better experience, you can put an .xsd file in \program files\microsoft visual studio 8\xml\schemas\
XSD Schema doesn't do a great job on XAML intellisense…but it is better that typing blind! The danger is that the schema isn't perfect. It complains about some syntaxes that are perfectly valid (according to the XAML loader and XAML compiler.) It also suggests some syntaxes which won't compile.
Why doesn't XSD do a great job with XAML?
Why is XSD inappropriate as a XAML validator:
1) Type Inheritance - 3rd party types that subclass UIElement should be allowed in DockPanel.
2) Generics - Generic collection type List -- content model depends on T
foo
foo
3) Attached Properties - AttachedProperties could be applied anywhere. Should all attached properties be added to the schema for all UIElements?
4) Attributes and Property Elements shouldn't both be set
The parser/compiler will both error if you do this. I'm not sure of way to enforce this with XSD.
...
5) PropertyElements must all be listed in the schema or they will appear invalid.
I choose to not list every PropertyElement as a possible child of the ObjectElements today because they would provide too many options to insert as children of tags. I've tried to find the common PropertyElements and add them to the schema.
The solution
Short term: tell us about bad problems in the xsd. We'll fix most of those until we get our long term solution.
Long term: we hope to have an editor that doesn't rely on XSD to provide intellisense. If you are building tools that are targetting Avalon/Xaml, and want to learn more about what I'd recommend in this area, please contact me...I'd be happy to tell you what I believe would be the best way to do this.
Update: I needed to hand escape all my tag examples...fixed them...