private static pwReturnCommandBehavior GetOrCreateBehavior(PasswordBox pwBox) { pwReturnCommandBehavior behavior = pwBox.GetValue(pwReturnCommandBehaviorProperty) as pwReturnCommandBehavior; if (behavior == null) { behavior = new pwReturnCommandBehavior(pwBox); pwBox.SetValue(pwReturnCommandBehaviorProperty, behavior); } return behavior; }
private static IReturnCommandBehavior ResolveCommandBehavior(DependencyObject ctrl) { IReturnCommandBehavior behavior; if (ctrl.GetType() == typeof(TextBox)) behavior = new ReturnCommandBehavior((TextBox)ctrl); else if (ctrl.GetType() == typeof(PasswordBox)) behavior = new pwReturnCommandBehavior((PasswordBox)ctrl); else behavior = null; return behavior; }