private static void OnSetCommandParameterCallback(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs e) { IApplicationBarMenuItem item = dependencyObject as IApplicationBarMenuItem; if (item != null) { AppBarItemCommandBehavior <IApplicationBarMenuItem> behavior = GetOrCreateBehavior(item); behavior.CommandParameter = e.NewValue; } }
private static AppBarItemCommandBehavior <IApplicationBarMenuItem> GetOrCreateBehavior(IApplicationBarMenuItem item) { AppBarItemCommandBehavior <IApplicationBarMenuItem> behavior = (item as FrameworkElement).GetValue(ClickCommandBehaviorProperty) as AppBarItemCommandBehavior <IApplicationBarMenuItem>; if (behavior == null) { behavior = new AppBarItemCommandBehavior <IApplicationBarMenuItem>(item); (item as FrameworkElement).SetValue(ClickCommandBehaviorProperty, behavior); } return(behavior); }