private static void SetupContent(Button button, UICommand command) { var contentControl = new CommandContentControl(); contentControl.SetBinding(CommandContentControl.LabelProperty, "Label"); contentControl.DataContext = command.ClientCommand; var uri = CommandImageService.GetCommandImageUri(command); if (uri != null) { contentControl.ImageSource = new BitmapImage(uri); } button.Content = contentControl; }
private static void SetupContent(MenuItem menuItem, UICommand command) { menuItem.DataContext = command.ClientCommand; menuItem.SetBinding(MenuItem.HeaderProperty, "Label"); if (UseCommandImage && menuItem.Icon == null && command != null) { Uri imageUri = CommandImageService.GetCommandImageUri(command); if (imageUri != null) { try { menuItem.Icon = new Image { Stretch = Stretch.None, Source = new BitmapImage(imageUri) }; } catch { } } } }