Fix for invalid XAML error - the member is not recognized or accessible when using ControlTemplate

by APIJunkie 16. December 2008 05:26

I've recently encountered an error that only appears when working on XAML in blend and not when working on XAML in VS.

Blend is apparently more sensitive then Visual studio 2008 when it comes to type checking templates.

If you forget to set the TargetType in a ControlTemplate and access certain properties in the content presenter, Blend will report an error and you will not be able to edit the XAML in design mode.

Note that this error only effects design mode in blend, the XAML still compiles and works perfectly (assuming we apply the template to the correct type).


Ok on blend, ok on VS 2008 ->

<ControlTemplate x:Key="MyXTemplate" TargetType="MyClassType">

Invalid XAML error on blend, ok on VS 2008 ->

<ControlTemplate x:Key="MyXTemplate">

For the error to appear you will also have to access non globally shared properties in the content presenter.

In the example below we try to set a content property which is not guaranteed to exist in the type we apply the template to.


<ContentPresenter Content="{TemplateBinding Content}" />



Silverlight | PRB | Troubleshoot | Blend


12/16/2008 6:53:52 AM #


Trackback from

Fix for invalid XAML error the member is not recognized or accessible

12/16/2008 5:02:16 PM #


Trackback from Community Blogs

Silverlight Cream for December 16, 2008 - 2 -- #458

Community Blogs

12/17/2008 12:19:56 AM #


Pingback from

2008 December 17 - Links for today « My (almost) Daily Links

Comments are closed

About the author

Name of author

I was first wounded by x86 assembly, recovered and moved on to C. Following a long addiction to C++ and a short stint at rehab I decided to switch to a healthier addiction so I am now happily sniffing .NET and getting hooked on Silverlight.

I am mainly here to ramble about coding, various API’s, Junkies(me especially) and everything else that happens between coders and their significant other.

  James Bacon