Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't use silverlight namespace

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?

like image 304
Josh Avatar asked Aug 18 '10 15:08

Josh


2 Answers

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.

like image 124
AnthonyWJones Avatar answered Nov 13 '22 23:11

AnthonyWJones


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>
like image 21
Dan Auclair Avatar answered Nov 14 '22 01:11

Dan Auclair