Visual Studio designer is broken using Expression Blend SDK Behavior

I am having a problem with the new Expression Blend behavior.

I have a custom class Behavior<T>

developed using the Expression Blend 3 SDK.

The behavior works correctly and the solution compiles. It's perfect. I have all my references (System.Windows.Interactivity.dll + Microsoft.Expression.Interactions.dll) in my projects that reference the behavior.

Also, as I mentioned, Visual Studio compiles the project perfectly.

However, if I load the XAML file into the Visual Studio designer, I get the following error after the solution compiles:

Error 1 Binding property "Behavior" was not found in type "Interaction". C: \ Path \ To \ MyFile.xaml 19 14 MyApplication

This line of the file is the first line of the following:

<Interactivity:Interaction.Behaviors>
    <Behaviors:DoubleTextBoxBehavior />
</Interactivity:Interaction.Behaviors>

      

My window setup is related to:

xmlns:Interactivity="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"

      

I even ruled out my usual behavior as an opportunity. I can simply include the following line and "break" the constructor:

<Interactivity:Interaction.Behaviors />

      

As far as I can tell, this should work. There should be no mistakes. The compiler does a great job with this, but Visual Studio won't load this into the constructor anytime I add a behavior line.

Does anyone have any idea what might be causing this and how to fix it?


Edit:

I ran some more tests and this seems to be an error only occurring in Windows Presentation Foundation Designer windows in Visual Studio 2008 (with sp1). The project works fine and no error is reported if I only use the XML editor. However, if I open this in the constructor, it reports an error and shows the loading problem constructor.

The error does not appear if the XAML file is not open in VS Designer.

+2


source to share


3 answers


This is due to a known issue in Visual Studio and has been fixed by hotfix KB958017 .



You can fix this by downloading and installing KB958017 Cumulative Fixes for Visual Studio Designer .

+3


source


I tried to reproduce your problem but was unable. I created the following WPF application:

<Window x:Class="WpfBehaviorsTest.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Interactivity="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
Title="Window1" Height="300" Width="300">
<Grid>
    <Interactivity:Interaction.Behaviors/>
</Grid>
</Window>

      

Everything works fine before and after compiling my project. Could you please check if this works for you? What version of MS Blend SDK are you using? Which version of Visual Studio? Just to be sure, we're talking about a WPF application, not a Silverlight application, right?



Update: You have exactly the same configuration as that of me. The only problem is that it works here, but it doesn't work on your side. Let the squat be an insect with the following checks:

  • Which version of the "System.Windows.Interactivity" assembly is loaded by the designer? You can start another instance of MS Visual Studio and connect to the first VS process using the "buggy" -designer. Go to Debug-> Windows-> Modules and check your System.Windows.Interactivity.dll version. If it looks good, you can still go ahead and double check it with Reflector. Does it have an interaction class? Does it have a BehaviorsProperty behavior in it?

  • What exactly is going on inside? If the build we checked in step 1 is correct, let's fire up the heavy artillery. In fact, I use this approach effectively quite often, whenever I have problems with the VS / Blend designer. Just start another instance of Visual Studio. Enable breaks on all CLR exceptions (Debug -> Exceptions -> Check the box after CLR exceptions). It can also help enable . Debug .NET source code . Attach an invalid constructor to the instance. Reload the designer. Now, instead of seeing a confusing message, the attached Studio will lead us to the very heart of the Exception. What is there?

+1


source


I am using VS2010 and I experienced the same problem but found a solution.

I had two projects in my solution. Project "A" that used behavior in a silverlight control (defined in xaml). Then I referenced the control in project A in the active Silverlight project B that was running. I kept getting the error Attached property "Behavior" was not found in type "Interaction"

When I added the System.Windows.Interactivity reference to project "B", it fixed my runtime error.

I'm not sure why this link didn't load because it was used by a control from project "A", but it doesn't. Oh good.

+1


source







All Articles