Communication between mudules in separate assemblies

Jun 17, 2010 at 11:17 AM

Hi,

What is the best way of handling events (specially mouse over) between modules that is in separate assemblies?

Is your Mediator service the correct way to do this? I want to handle mouse over and send an event to the StatusBar (that is in a seperate module).

Coordinator
Jun 17, 2010 at 11:31 AM
when ever you want to talk from one module to another Mediator should do the trick

Regards
Marlon
WPF Blog - http://marlongrech.wordpress.com/
Microsoft MVP for Client App



On Thu, Jun 17, 2010 at 12:17 PM, pcedendahl <notifications@codeplex.com> wrote:
this

Jun 17, 2010 at 11:37 AM

So there is not performance or memory related problems using the Mediator in this way?

Coordinator
Jun 17, 2010 at 11:39 AM

Mediator is quite high perf so I wouldn't worry about it... what are the scenarios for use?

Regards
Marlon
WPF Blog - http://marlongrech.wordpress.com/
Microsoft MVP for Client App



On Thu, Jun 17, 2010 at 12:38 PM, pcedendahl <notifications@codeplex.com> wrote:

From: pcedendahl

So there is not performance or memory related problems using the Mediator in this way?

Read the full discussion online.

To add a post to this discussion, reply to this email (MEFedMVVM@discussions.codeplex.com)

To start a new discussion for this project, email MEFedMVVM@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com


Jun 17, 2010 at 12:01 PM

I have a main window that is structured in regions and UserControls are imported and put in these regions. One of the module is the StatusBar (or BottomFrame I called it) where I want to show descriptions when mouse over occurs in fields etc in the other modules.

Jun 17, 2010 at 12:56 PM

Think I need an Event To Command behaviour for this or?

Jun 18, 2010 at 6:50 AM
I have tried getting the MouseEnter and MouseLeave to work but I can't get it working. I have tried the Mvvm Light's EventToCommand without luck. Do you have any suggestions? I want the MouseEnter event to call a command in the ViewModel som I can use your Mediatior to send a message to my StatusBar that is in a separate assembly (module)
Coordinator
Jun 18, 2010 at 8:36 AM
You can do an attached property that executes a command for you when the mouse over event is fired...

another generic way is to use something like this
http://marlongrech.wordpress.com/2008/12/13/attachedcommandbehavior-v2-aka-acb/

Regards
Marlon
WPF Blog - http://marlongrech.wordpress.com/
Microsoft MVP for Client App



On Fri, Jun 18, 2010 at 7:50 AM, pcedendahl <notifications@codeplex.com> wrote:

From: pcedendahl

I have tried getting the MouseEnter and MouseLeave to work but I can't get it working. I have tried the Mvvm Light's EventToCommand without luck. Do you have any suggestions? I want the MouseEnter event to call a command in the ViewModel som I can use your Mediatior to send a message to my StatusBar that is in a separate assembly (module)

Read the full discussion online.

To add a post to this discussion, reply to this email (MEFedMVVM@discussions.codeplex.com)

To start a new discussion for this project, email MEFedMVVM@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com


Jun 18, 2010 at 8:58 AM
Is it easy to implement this into your framework by my self you think?
Coordinator
Jun 18, 2010 at 9:01 AM
you can do it something like this... create a class to define the attached properties... here is s sample that handles MouseLeftButtonUp... all you need to do is change it to handle Mouse over


 #region Command

        /// <summary>
        ///   Command Attached Dependency Property
        /// </summary>
        public static readonly DependencyProperty CommandProperty =
            DependencyProperty.RegisterAttached("Command", typeof (ICommand), typeof (CommandBehaviour),
                                                new PropertyMetadata((ICommand) null));

        /// <summary>
        ///   Gets the Command property.  This dependency property
        ///   indicates ....
        /// </summary>
        public static ICommand GetCommand(DependencyObject d)
        {
            return (ICommand) d.GetValue(CommandProperty);
        }

        /// <summary>
        ///   Sets the Command property.  This dependency property
        ///   indicates ....
        /// </summary>
        public static void SetCommand(DependencyObject d, ICommand value)
        {
            d.SetValue(CommandProperty, value);
        }

        #endregion

        #region CommandParameter

        /// <summary>
        ///   CommandParameter Attached Dependency Property
        /// </summary>
        public static readonly DependencyProperty CommandParameterProperty =
            DependencyProperty.RegisterAttached("CommandParameter", typeof (object), typeof (CommandBehaviour),
                                                new PropertyMetadata((object) null));

        /// <summary>
        ///   Gets the CommandParameter property.  This dependency property
        ///   indicates ....
        /// </summary>
        public static object GetCommandParameter(DependencyObject d)
        {
            return d.GetValue(CommandParameterProperty);
        }

        /// <summary>
        ///   Sets the CommandParameter property.  This dependency property
        ///   indicates ....
        /// </summary>
        public static void SetCommandParameter(DependencyObject d, object value)
        {
            d.SetValue(CommandParameterProperty, value);
        }

        #endregion

        #region HandleMouseLeftButtonUp

        /// <summary>
        ///   HandleMouseLeftButtonUp Attached Dependency Property
        /// </summary>
        public static readonly DependencyProperty HandleMouseLeftButtonUpProperty =
            DependencyProperty.RegisterAttached("HandleMouseLeftButtonUp", typeof (bool), typeof (CommandBehaviour),
                                                new PropertyMetadata(false,
                                                                     OnHandleMouseLeftButtonUpChanged));

        /// <summary>
        ///   Gets the HandleMouseLeftButtonUp property.  This dependency property
        ///   indicates ....
        /// </summary>
        public static bool GetHandleMouseLeftButtonUp(DependencyObject d)
        {
            return (bool) d.GetValue(HandleMouseLeftButtonUpProperty);
        }

        /// <summary>
        ///   Sets the HandleMouseLeftButtonUp property.  This dependency property
        ///   indicates ....
        /// </summary>
        public static void SetHandleMouseLeftButtonUp(DependencyObject d, bool value)
        {
            d.SetValue(HandleMouseLeftButtonUpProperty, value);
        }

        /// <summary>
        ///   Handles changes to the HandleMouseLeftButtonUp property.
        /// </summary>
        private static void OnHandleMouseLeftButtonUpChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            var element = (UIElement) d;
            if ((bool) e.NewValue)
                element.MouseLeftButtonUp += ElementMouseLeftButtonUp;
            else
                element.MouseLeftButtonUp -= ElementMouseLeftButtonUp;
        }

        private static void ElementMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            var command = GetCommand((DependencyObject)element);
            if (command != null && command.CanExecute(GetCommandParameter(element)))
                command.Execute(GetCommandParameter(element));
        }

        #endregion

Regards
Marlon
WPF Blog - http://marlongrech.wordpress.com/
Microsoft MVP for Client App



On Fri, Jun 18, 2010 at 9:58 AM, pcedendahl <notifications@codeplex.com> wrote:

From: pcedendahl

Is it easy to implement this into your framework by my self you think?

Read the full discussion online.

To add a post to this discussion, reply to this email (MEFedMVVM@discussions.codeplex.com)

To start a new discussion for this project, email MEFedMVVM@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com


Jun 18, 2010 at 9:10 AM
Thank's for the help. I will try this.