Example #1
0
        internal protected virtual void OnViewModelEventInternal(ViewModelEventArgs args)
        {
            OnViewModelEvent(args);

            if (args.IsHandled)
                return;

            if (ViewModel != null)
            {
                // todo: update interface
                (ViewModel as ViewModel).OnViewModelEventInternal(args);
            }
        }
Example #2
0
 protected virtual void OnViewModelEvent(ViewModelEventArgs args)
 { }
Example #3
0
        void RaiseViewModelEvent(IViewModel vm, IViewModelEvent ev, ViewModelEventRoutingStrategy routingStrategy)
        {
            if (routingStrategy.HasFlag(ViewModelEventRoutingStrategy.Bubble))
            {
                var preview_args = new ViewModelEventArgs(vm, ev, ViewModelEventRoutingStrategy.Bubble);

                // Raise Bubbling WPF Routed Event
                var wpf_preview_args = new ViewModelEventRoutedEventArgs(preview_args, PreviewViewModelEventProperty, this);

                RaiseEvent(wpf_preview_args);

                if (wpf_preview_args.Handled || preview_args.IsHandled)
                    return;
            }

            if (routingStrategy.HasFlag(ViewModelEventRoutingStrategy.Tunnel))
            {
                var args = new ViewModelEventArgs(vm, ev, ViewModelEventRoutingStrategy.Tunnel);

                // Raise Tunneling WPF Routed Event
                var wpf_args = new ViewModelEventRoutedEventArgs(args, ViewModelEventProperty, this);

                RaiseEvent(wpf_args);

                if (wpf_args.Handled || args.IsHandled)
                    return;
            }

            if(routingStrategy.HasFlag(ViewModelEventRoutingStrategy.BroadcastToChildren))
            {
                // search visual tree for children deriving from View

                var children = 
                    this.VisualTreeTraversal(
                    includeChildItemsControls: true, 
                    traversalMode: TreeTraversalMode.BreadthFirst)
                    .OfType<View>();

                var args = new ViewModelEventArgs(vm, ev, ViewModelEventRoutingStrategy.BroadcastToChildren);

                foreach (var v in children)
                {
                    v.OnViewModelEventInternal(args);

                    if (args.IsHandled)
                        return;
                }
            }
        }
 public ViewModelEventRoutedEventArgs(ViewModelEventArgs args, RoutedEvent routedEvent, object source)
     : base(routedEvent, source)
 {
     this.ViewModelEventArgs = args;
 }
        protected override void OnViewModelEvent(ViewModelEventArgs args)
        {
            base.OnViewModelEvent(args);

            if(args.RoutingStrategy == ViewModelEventRoutingStrategy.Tunnel)
            {
                if (!HandleTunnelEvents)
                    return;

                Messages = 
                    "{0}: RECEIVED Tunnel Event {1}"
                    .FormatWith(GetNextMessageNumber(), args.Event.Name)
                    + Environment.NewLine
                    + Messages;
            }

            if (args.RoutingStrategy == ViewModelEventRoutingStrategy.BroadcastToChildren)
            {
                if (!HandleTunnelEvents)
                    return;

                Messages = 
                    "{0}: RECEIVED Broadcast To Children Event {1}"
                    .FormatWith(GetNextMessageNumber(), args.Event.Name)
                    + Environment.NewLine
                    + Messages;
            }
        }
        protected override void OnPreviewViewModelEvent(ViewModelEventArgs args)
        {
            base.OnPreviewViewModelEvent(args);

            if (!HandleBubbleEvents)    
                return;

            Messages = 
                "{0}: RECEIVED Bubble Event {1}"
                .FormatWith(GetNextMessageNumber(), args.Event.Name)
                + Environment.NewLine
                + Messages;
        }