0

I am trying to execute the following xaml code which has reference to interactivity and interactions as shown and I keep getting errors.

The xaml code is attached below with the comments where errors are appearing.

<Grid 
    xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
    xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions">

    <Popup x:Name="popup" PlacementTarget="{Binding ElementName=imageList}">
        <Image Source="{Binding PlacementTarget.SelectedItem , ElementName=popup}"/>
    </Popup>
    <ListView x:Name="imageList" >
        <i:Interaction.Triggers>  //ERROR
            <i:EventTrigger EventName="SelectionChanged"> //ERROR
                <ei:ChangePropertyAction PropertyName="IsOpen" 
                    TargetName="{Binding ElementName=popup}" Value="True"/> //ERROR
            </i:EventTrigger>
        </i:Interaction.Triggers>
    </ListView>
</Grid>

I want to display selected image in a new window. But the following errors occur.

tobsob
  • 602
  • 9
  • 22
Mr.Shark
  • 128
  • 1
  • 1
  • 10
  • 2
    You missed the errors off but I guess your issue is because you haven't referenced the dll in your project. Which I think is now a nuget package https://www.nuget.org/packages/Microsoft.Xaml.Behaviors.Wpf/ – Andy Oct 10 '19 at 13:08

2 Answers2

2

You need to add references (Project->Add Reference->Assemblies in Visual Studio) to System.Windows.Interactivity.dll and Microsoft.Expressions.Interactions.dll.

They are part of the Blend SDK which can be downloaded from microsoft.com or by installing this NuGet package (Tools->Nuget Package Manager->Package Manager Console) into your project.

mm8
  • 163,881
  • 10
  • 57
  • 88
1

Encountered the same errors while working with an Elmish.WPF project's C# Sample project 'NewWindow'. The solution was found in this StackOverflow Q&A: Interaction triggers inside DataTemplate not working with XamlReader.

The answer for me was to add :

        xmlns:i="http://schemas.microsoft.com/xaml/behaviors"

... to the XAML page's defintions at top. And add the Nuget package Microsoft.Xaml.Behaviors.Wpf (I'm working with a WPF project, you might just want Microsoft.Xaml.Behaviors).

rfreytag
  • 955
  • 1
  • 8
  • 24