/// <summary> /// Change handler for the event name /// </summary> /// <param name="dpo">VMTrigger object</param> /// <param name="e">EventArgs</param> private static void OnEventNameChanged(DependencyObject dpo, DependencyPropertyChangedEventArgs e) { ViewModelTriggerBehavior vmt = (ViewModelTriggerBehavior)dpo; if (vmt.Target == null) { return; } string oldEventName = e.OldValue as string; if (!string.IsNullOrEmpty(oldEventName)) { vmt.UnregisterEvent(vmt.Target, oldEventName); } vmt.RegisterEvent(vmt.Target, vmt.EventName); }
/// <summary> /// Change handler for the event name /// </summary> /// <param name="dpo">VMTrigger object</param> /// <param name="e">EventArgs</param> private static void OnTargetChanged(DependencyObject dpo, DependencyPropertyChangedEventArgs e) { ViewModelTriggerBehavior vmt = (ViewModelTriggerBehavior)dpo; if (string.IsNullOrEmpty(vmt.EventName)) { return; } object oldTarget = e.OldValue; if (oldTarget != null) { vmt.UnregisterEvent(oldTarget, vmt.EventName); } vmt.RegisterEvent(vmt.Target, vmt.EventName); }