CSLA .NET

Vibrant discussion about CSLA .NET and using the framework to build great business applications.

Forum has moved

New location: CSLA .NET forum


CSLA .NET Resources:
  • CSLA .NET forum
  • CSLA .NET home page
  • multiple csla:InvokeMethods on a control

    rated by 0 users
    Answered (Verified) This post has 1 verified answer | 4 Replies | 1 Follower

    Not Ranked
    4 Posts
    Martino posted on Fri, Feb 19 2010 10:59 AM

    This might be more of a WPF question, but is it possible to set multiple csla:InvokeMethods on one control?

    for example a csla:InvokeMethod.TriggerEvent for  the click event and one for the MouseEnter event of a button?

    This obviously won't work

    <Button

    csla:InvokeMethod.TriggerEvent="Click"

    csla:InvokeMethod.MethodName = "OnClickHandler"

    csla:invokeMethod.TriggerEvent="MouseEnter"

    csla:InvokeMethod.MethodName = "OnMouseEnterHandler"/>

     

    I've also seen some refernces made to a MVVM example, is this the MVVMExperiment project? If not where do i find the MVVM example?

     

    btw. Love the new modelview stuff in 3.8.0

     

    Answered (Verified) Verified Answer

    Not Ranked
    4 Posts
    Answered (Verified) Martino replied on Thu, Feb 25 2010 10:10 AM
    Verified by RockfordLhotka

    Just in case somebody ran into the same issue. Here is Rockys response:

    Unfortunately InvokeMethod is an attached property (actually a set of related attached properties), so there’s no real way to have more than one of them attached to a control – at least not that I know of.

     Execute is a trigger action based on the event trigger concepts defined by Blend 3 in their SDK. They don’t expose as much information to a trigger action as I can get as an attached property, which restricts what Execute can do to solve this problem. In short, Execute can’t do the “live binding” that InvokeMethod does, because trigger actions just don’t have enough information to do that.

     In CSLA 4 I’ve implemented yet another solution, called TriggerAction. This is a standalone control, which is required to work with the Visual Studio 2010 designer.

    http://www.lhotka.net/weblog/ApplyingMVVMInTheVS10XAMLDesigner.aspx

     Right now it doesn’t do the “live binding” that InvokeMethod does either. But I suppose it probably should include that functionality.

     The advantage of TriggerAction, is that you can have as many of them as you’d like, all attached to different (or even the same) events of a given UI control. So the flexibility is substantially greater than with InvokeMethod.

     You can see the code here

    http://www.lhotka.net/cslacvs/viewvc.cgi/core/branches/V4-0-0-RC/Source/Csla.Xaml/TriggerAction.cs?view=markup

     But as I said, the MethodParameter functionality from InvokeMethod needs to be merged into this control for it to fully address your scenario.

    Rocky

    All Replies

    Not Ranked
    4 Posts
    Martino replied on Tue, Feb 23 2010 12:27 PM

    Any ideas?

    Top 25 Contributor
    238 Posts

    I remember a similar post but even though I searched for it I could not find it.

    I think the only way to achieve this you will need to use the trigger method:

    <Button Content="Click Me">
      <i:Interaction.Triggers>
        <i:EventTrigger EventName="Click">
          <csla:Execute MethodName="LoadData" />
        </i:EventTrigger> 
        <i:EventTrigger EventName="MouseOver">
          <csla:Execute MethodName="AnimateMe" />
        </i:EventTrigger> 
       ...
      </i:Interaction.Triggers>
    </Button>

    I know this is not exactly what you are looking for but thought I'd let you know anyway.

    Not Ranked
    4 Posts

    This would work in most cases.

    In my case I need to databind to the (non-bindable) SelectedItems for both triggers. For that i'd like to use Rockys work around:

    csla:InvokeMethod.MethodParameter="{Binding ElementName=myGrid, Path=SelectedItems}"

    with a dependency property 'SelectedItems' in the ViewModel

    I've looked at using multibinding, but i'm kinda stuck there too.

     

    Not Ranked
    4 Posts
    Answered (Verified) Martino replied on Thu, Feb 25 2010 10:10 AM
    Verified by RockfordLhotka

    Just in case somebody ran into the same issue. Here is Rockys response:

    Unfortunately InvokeMethod is an attached property (actually a set of related attached properties), so there’s no real way to have more than one of them attached to a control – at least not that I know of.

     Execute is a trigger action based on the event trigger concepts defined by Blend 3 in their SDK. They don’t expose as much information to a trigger action as I can get as an attached property, which restricts what Execute can do to solve this problem. In short, Execute can’t do the “live binding” that InvokeMethod does, because trigger actions just don’t have enough information to do that.

     In CSLA 4 I’ve implemented yet another solution, called TriggerAction. This is a standalone control, which is required to work with the Visual Studio 2010 designer.

    http://www.lhotka.net/weblog/ApplyingMVVMInTheVS10XAMLDesigner.aspx

     Right now it doesn’t do the “live binding” that InvokeMethod does either. But I suppose it probably should include that functionality.

     The advantage of TriggerAction, is that you can have as many of them as you’d like, all attached to different (or even the same) events of a given UI control. So the flexibility is substantially greater than with InvokeMethod.

     You can see the code here

    http://www.lhotka.net/cslacvs/viewvc.cgi/core/branches/V4-0-0-RC/Source/Csla.Xaml/TriggerAction.cs?view=markup

     But as I said, the MethodParameter functionality from InvokeMethod needs to be merged into this control for it to fully address your scenario.

    Rocky

    Page 1 of 1 (5 items) | RSS

    Copyright (c) 2006-2014 Marimer LLC. All rights reserved.
    Email admin@lhotka.net for support.
    Powered by Community Server (Non-Commercial Edition), by Telligent Systems