<RibbonWindow x:Class="RibbonWorkaround.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="350" Width="525"> <DockPanel x:Name="dockPanel"> <Ribbon x:Name="mainRibbon" DockPanel.Dock="Top" IsMinimized="False" > <RibbonTab Header="Tab"> <RibbonGroup Header="Test Group"> <RibbonButton Click="test_Click" Label="Test Button" /> <RibbonComboBox x:Name="testSelectionCombo" SelectionBoxWidth="80"> <RibbonGallery x:Name="testSelection" MaxColumnCount="1" > <RibbonGalleryCategory x:Name="testSelectionCat" > <RibbonGalleryItem IsSelected="True">Test 1</RibbonGalleryItem> <RibbonGalleryItem>Test 2</RibbonGalleryItem> <RibbonGalleryItem>Test 3</RibbonGalleryItem> </RibbonGalleryCategory> </RibbonGallery> </RibbonComboBox> </RibbonGroup> </RibbonTab> </Ribbon> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="*"/> <ColumnDefinition Width="*"/> </Grid.ColumnDefinitions> <Button Click="Disable_Click" >Disable Ribbon</Button> <Button Grid.Column="1" Click="Enable_Click" >Enable Ribbon</Button> </Grid> </DockPanel> </RibbonWindow>
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; using System.Windows.Controls.Ribbon; namespace RibbonWorkaround { /// <summary> /// Interaction logic for MainWindow.xaml /// </summary> public partial class MainWindow:RibbonWindow { public MainWindow() { InitializeComponent(); } private void Disable_Click(object sender,RoutedEventArgs e) { mainRibbon.IsEnabled=false; } private void Enable_Click(object sender,RoutedEventArgs e) { mainRibbon.IsEnabled=true; } private void test_Click(object sender,RoutedEventArgs e) { Console.Beep(); } } }
public MainWindow() { InitializeComponent(); testSelection.Command=ApplicationCommands.Print; // only dummy to force RibbonGallery to initialize properly testSelection.Command=null; }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)