RibbonMenuButton Issue
-
Wednesday, August 22, 2012 8:01 PM
I am working on a WPF project and I started developing the
Ribbonarea. I just put aRibbonMenuButtonand added threeRibbonTextBoxinside of it. I want these TextBoxes to retrieve some data from the user. Everything is fine so far.<rb:RibbonMenuButton LargeImageSource="/image.png" Label="Settings" > <rb:RibbonTextBox Label="Field 01:" Text="{Binding Field01 }" /> <rb:RibbonTextBox Label="Field 02:" Text="{Binding Field02 }" /> <rb:RibbonTextBox Label="Field 03:" Text="{Binding Field03 }" /> </rb:RibbonMenuButton>My problem is that the
RibbonTextBoxbecomes a menu item, i.e. I can click it and select it.But I want to avoid this behavior, I just want to have an "unselectable"
RibbonTextBox.Is there a way to achieve that?
Thank you in advance.
All Replies
-
Wednesday, August 22, 2012 9:43 PMModerator
Hiya
I think the simplest way is to change the RibbinMenuItem ControlTemplate:
<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:rb="http://schemas.microsoft.com/winfx/2006/xaml/presentation/ribbon" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:Microsoft_Windows_Themes="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Classic" mc:Ignorable="d" x:Class="WpfApplication70.MainWindow" Title="MainWindow" Height="350" Width="525"> <Window.Resources> <Style TargetType="{x:Type rb:RibbonMenuItem}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type rb:RibbonMenuItem}"> <ContentPresenter ContentTemplate="{TemplateBinding HeaderTemplate}" Content="{TemplateBinding Header}" Grid.Column="1" ContentStringFormat="{TemplateBinding HeaderStringFormat}" ContentSource="Header" Margin="{TemplateBinding Padding}" RecognizesAccessKey="True" VerticalAlignment="Center"/> </ControlTemplate> </Setter.Value> </Setter> </Style> </Window.Resources> <Grid> <rb:Ribbon HorizontalAlignment="Left" Margin="111,86,0,88.867" Width="289.14"> <rb:RibbonMenuButton Label="Settings" > <rb:RibbonTextBox Label="Field 01:" Text="{Binding Field01}" /> <rb:RibbonTextBox Label="Field 02:" Text="{Binding Field02}" /> <rb:RibbonTextBox Label="Field 03:" Text="{Binding Field03}" /> </rb:RibbonMenuButton> </rb:Ribbon> </Grid> </Window>Put this in <rb:RibbonMenuButton.Resources> if you want it to stay local to that button.
Regards,
Pete
#PEJL
- Edited by XAML guyMicrosoft Community Contributor, Moderator Wednesday, August 22, 2012 9:46 PM added resources comment
- Marked As Answer by Dante24 Thursday, August 23, 2012 3:22 PM
-
Thursday, August 23, 2012 3:32 PMWorks perfectly, thank you very much!

