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

by APIJunkie 12/16/2008 5:26:00 AM
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).

Example:

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.

Example:

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

 

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

Silverlight | PRB | Troubleshoot | Blend

Comments

12/16/2008 6:53:52 AM

trackback

Trackback from DotNetKicks.com

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

DotNetKicks.com

12/16/2008 5:02:16 PM

trackback

Trackback from Community Blogs

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

Community Blogs

12/17/2008 12:19:56 AM

pingback

Pingback from mgalinks.wordpress.com

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

mgalinks.wordpress.com

Add comment


(Will show your Gravatar icon)  

  Country flag





Live preview

7/3/2009 3:08:45 PM

Powered by BlogEngine.NET 1.2.0.0
Theme by Mads Kristensen

About the author

Name of author

My name is Bacon…James Bacon.

I am an API wars veteran I was 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.

E-mail me Send mail


Calendar

<<  July 2009  >>
MoTuWeThFrSaSu
293012345
6789101112
13141516171819
20212223242526
272829303112
3456789

View posts in large calendar

Recent comments

Authors

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2009

Sign in