views:

110

answers:

2

Whenever I try to reference the following namespace in my XAML, the code compiles and the project starts, but the InitializeComponent method throws an error. Here's the XAML reference:

xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions"

and here's the use of ExtendedVisualStateManager

<ei:ExtendedVisualStateManager/>

The error is this:

The type 'ExtendedVisualStateManager' was not found because 'http://schemas.microsoft.com/expression/2010/interactions' is an unknown namespace. [Line: 19 Position: 37]

Is there a new namespace I need to use to use this control?

+1  A: 

Make sure your Silverlight application has a reference to the Microsoft.Expression.Interactions assembly.

<UserControl
    xmlns:ei="clr-namespace:Microsoft.Expression.Interactivity.Core;assembly=Microsoft.Expression.Interactions"
    ...other namespaces... />
    <VisualStateManager.CustomVisualStateManager>
        <ei:ExtendedVisualStateManager/>
    </VisualStateManager.CustomVisualStateManager>
</UserControl>
Dan Auclair
I already had that assembly referenced and tried using your style of referencing the assembly, but a new error was thrown :The type 'ExtendedVisualStateManager' was not found because 'clr-namespace:Microsoft.Expression.Interactivity.Core;assembly=Microsoft.Expression.Interactions' is an unknown namespace. [Line: 19 Position: 37]
Josh
+1  A: 

Here are some facts.

  1. The Microsoft.Expression.Interactions.dll version 4.0.5.0 contains the namespace Microsoft.Expression.Interactivity.Core.
  2. This Microsoft.Expression.Interactivity.Core contains the type ExtendedVisualStateManager.
  3. The Microsoft.Expression.Interactions.dll version 4.0.5.0 carries a XmlnsDefinition that maps the URL "http://schemas.microsoft.com/expression/2010/interactions" to the namespace Microsoft.Expression.Interactivity.Core.

Hence a project referencing version 4.0.5.0 of Microsoft.Expression.Interactions.dll can contain Xaml using xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions" that can then contain ei:ExtendedVisualStateManager.

You'll note I've repeated the version number a few times. If you do have an interactions dll referenced in a Silverlight 4 project but your code doesn't work then perhaps its the wrong version. However in that case Dan's answer should still have worked.

AnthonyWJones