I am using the Fluent Ribbon and got stuck with this problem. I have added some ribbon tab items and wanted to execute something if the user clicks on them
<Fluent:RibbonTabItem Name="TabItem" MouseLeftButtonDown="TabItem_MouseLeftButtonDown">
<Fluent:RibbonGroupBox Header="">
<Fluent:Button/>
<Fluent:Button/>
</Fluent:RibbonGroupBox>
<Fluent:RibbonGroupBox Header="">
<Fluent:Button Name="General" Header="General" Click="General_Click" />
</Fluent:RibbonGroupBox>
</Fluent:RibbonTabItem>
This is a simplified part of the code... however if i click on the General button the click event fires as expected but if i click the ribbon tab item nothing happens. Here are both event handlers
private void TabI开发者_StackOverflowtem_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
//some code
}
private void General_Click(object sender, RoutedEventArgs e)
{
//more code
}
Does anyone know how to fire this event?
It's simpler than you think: the Ribbon
class has a SelectedTabChanged
event.
It is fired twice every time you change tab:
- the first time the
System.Windows.Controls.SelectionChangedEventArgs
contains the old tab inRemovedItems
- the second time it contains the new tab in
AddedItems
.
Both those properties are an object[]
.
Just look for it in the property window or let the IntelliSense find it for you ;)
Try SelectionChanged event on Ribbon Object.
精彩评论