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}" />

 

Currently rated 5.0 by 1 people

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

Tags:

Silverlight | PRB | Troubleshoot | Blend

Step by step on how to upgrade Silverlight 2 beta 2 to Silverlight 2 RC0

by APIJunkie 10/3/2008 10:30:00 PM

Since I had to do this a couple of times on different machines I thought this might be useful for others.

Here is the list of steps I take to upgrade a Silverlight 2 beta 2 development machine to Silverlight 2 RC0.

First the pre requisites:

0.0 Because Blend version 2 can't live happily with older preview versions, you will need to uninstall Blend 2.5 June Preview or any other version of Blend 2 preview you may have on the machine.

0.1. You will need Visual Studio 2008 SP1 and .Net 3.5 SP1, so if you haven't done so before, install Visual Studio 2008 SP1(this will install .NET 3.5 SP1 as well).

Now the actual installation steps:

1. Install Microsoft Silverlight Tools for Visual Studio 2008 SP1(this will uninstall Silverlight 2 beta 2 SDK if need be...)

2. Install Blend 2 or Blend 2 trial version.

3. Install Blend 2 Service Pack 1 Preview.

You should be good to go.

Regarding breaking changes here are a couple we encountered:

1. The DataGridTextColumn property DisplayMemberBinding has been renamed to Binding.

2. TextAlignment was removed from button styles.
 

Good luck!

Currently rated 1.5 by 2 people

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

Tags:

Silverlight | Visual Studio | Blend

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

<<  March 2010  >>
MoTuWeThFrSaSu
22232425262728
1234567
891011121314
15161718192021
22232425262728
2930311234

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 2010

Sign in