private static void OnSetCommandParameterCallback(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs e) { Microsoft.Phone.Controls.PhoneApplicationPage buttonBase = dependencyObject as Microsoft.Phone.Controls.PhoneApplicationPage; if (buttonBase != null) { PhoneApplicationPageBackKeyPressCommandBehavior behavior = GetOrCreateBehavior(buttonBase); behavior.CommandParameter = e.NewValue; } }
private static PhoneApplicationPageBackKeyPressCommandBehavior GetOrCreateBehavior(Microsoft.Phone.Controls.PhoneApplicationPage buttonBase) { PhoneApplicationPageBackKeyPressCommandBehavior behavior = buttonBase.GetValue(BackKeyPressCommandBehaviorProperty) as PhoneApplicationPageBackKeyPressCommandBehavior; if (behavior == null) { behavior = new PhoneApplicationPageBackKeyPressCommandBehavior(buttonBase); buttonBase.SetValue(BackKeyPressCommandBehaviorProperty, behavior); } return(behavior); }