locked
Prism 4.1 can't use InvokeCommandAction RRS feed

  • Question

  • I develop WPF desktop application.

    I am trying to use InvoiceCommandAction for binding Close event to command

    I read here

    http://msdn.microsoft.com/en-us/library/gg405471%28v=pandp.40%29

    <TextBox>
      <i:Interaction.Triggers>
        <i:EventTrigger EventName="KeyUp">
            <prism:InvokeCommandAction Command="{Binding MyCommand}" />
        </i:EventTrigger>
      </i:Interaction.Triggers>
    </TextBox> 

    But the main question what should be in i set ?

    1. I added reference to

    Microsoft.Practices.Prism.Interactivity.dll

    2. And I set

    xmlns:i="clr-namespace:Microsoft.Practices.Prism.Interactivity;assembly=Microsoft.Practices.Prism.Interactivity"

    But it wrote that Interaction.Triggers doesn't exists in this namespace.

    Also I am truing to find sample which using it in 4.1. But there is no such example. Can you give some example on WPF which use to bind Close event to command.

    Also Iam trying using code from here

    http://stackoverflow.com/questions/3683450/handling-the-window-closing-event-with-wpf-mvvm-light-toolkit

    <i:Interaction.Triggers>
        <i:EventTrigger EventName="Closing">
            <command:EventToCommand Command="{Binding WindowClosing}" />
        </i:EventTrigger>
    </i:Interaction.Triggers>
    




    My .NET Extras. Coming soon : MVVM Dialog Service, EmptyIfNull ( LINQ ), CombineAsPath, Easy File Size Info

    Friday, June 8, 2012 2:52 PM

Answers

  • So I solve my problem.

    When I read Prism 4.1 document about binding event to command.

    I though that they included assemblies at their library.

    But later I undertood that they only add specific command which fixed bug existed in Expression Blend.

    So if you want to bind event to command using Prism 4.1 you need.

    1. Find Expression Blend assembly.System.Windows.Interactivity.dll.

    If you develop WPF application you need WPF kind System.Windows.Interactivity.dll assembly or you will have got exception.

    They are exist in 2 version for WPF and for Silverlight.

    Thank heaven I found it in MVVM Light Library.

    2. You add it to your project.

    3. Then you need to put namespace for this assembly, where you've got trigger and to prism, where you ve got fixed command

    ...
    xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
    xmlns:prism="clr-namespace:Microsoft.Practices.Prism.Interactivity;assembly=Microsoft.Practices.Prism.Interactivity"   
    ....
        

    One assembly from Exression Blend which you must find by itself.

    And another exists in Prism 4.1


    My .NET Extras. Coming soon : MVVM Dialog Service, EmptyIfNull ( LINQ ), CombineAsPath, Easy File Size Info


    • Edited by SmartWhy Tuesday, June 12, 2012 9:01 AM
    • Marked as answer by SmartWhy Tuesday, June 12, 2012 9:02 AM
    Tuesday, June 12, 2012 9:00 AM

All replies

  • Hi dcya,

    You could download Prism 4.1 from this link:

    http://www.microsoft.com/en-us/download/details.aspx?displaylang=en&id=28950

    and then there is a Prism.Interactivity project included, you could open this project and use InvokeCommandAction class in InvokeCommandAction.cs file in your needs.

    Best regards,


    Sheldon _Xiao[MSFT]
    MSDN Community Support | Feedback to us
    Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, June 11, 2012 3:52 PM
  • So I solve my problem.

    When I read Prism 4.1 document about binding event to command.

    I though that they included assemblies at their library.

    But later I undertood that they only add specific command which fixed bug existed in Expression Blend.

    So if you want to bind event to command using Prism 4.1 you need.

    1. Find Expression Blend assembly.System.Windows.Interactivity.dll.

    If you develop WPF application you need WPF kind System.Windows.Interactivity.dll assembly or you will have got exception.

    They are exist in 2 version for WPF and for Silverlight.

    Thank heaven I found it in MVVM Light Library.

    2. You add it to your project.

    3. Then you need to put namespace for this assembly, where you've got trigger and to prism, where you ve got fixed command

    ...
    xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
    xmlns:prism="clr-namespace:Microsoft.Practices.Prism.Interactivity;assembly=Microsoft.Practices.Prism.Interactivity"   
    ....
        

    One assembly from Exression Blend which you must find by itself.

    And another exists in Prism 4.1


    My .NET Extras. Coming soon : MVVM Dialog Service, EmptyIfNull ( LINQ ), CombineAsPath, Easy File Size Info


    • Edited by SmartWhy Tuesday, June 12, 2012 9:01 AM
    • Marked as answer by SmartWhy Tuesday, June 12, 2012 9:02 AM
    Tuesday, June 12, 2012 9:00 AM
  • Thanks for sharing your solution, this is exactly what I was looking for (and I found both DLL in the Prism 4.1 download).

    FYI, you can use these namespaces instead of the assembly names + clr-namespace:

    xmlns:prism="http://www.codeplex.com/prism"
    xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"

    Thursday, June 14, 2012 9:28 AM
  • good! thank you so much! you solved my problem(I'm from Beijing).
    Wednesday, May 8, 2013 3:02 AM