Fluent 功能区选项卡项目单击事件
我正在使用 Fluent Ribbon 并遇到了这个问题。我添加了一些功能区选项卡项目,并希望在用户单击它们时执行某些操作
<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>
这是代码的简化部分...但是,如果我单击“常规”按钮,则单击事件会按预期触发,但如果我单击功能区选项卡项目没有任何反应。这是两个事件处理程序
private void TabItem_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
//some code
}
private void General_Click(object sender, RoutedEventArgs e)
{
//more code
}
有人知道如何触发此事件吗?
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 TabItem_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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
它比您想象的要简单:
Ribbon
类有一个SelectedTabChanged
事件。每次更改选项卡时都会触发两次:
System.Windows.Controls.SelectionChangedEventArgs
包含RemovedItems
中的旧选项卡,RemovedItems
中的新选项卡添加项目
。这两个属性都是一个
object[]
。只需在属性窗口中查找它或让 IntelliSense 为您找到它;)
It's simpler than you think: the
Ribbon
class has aSelectedTabChanged
event.It is fired twice every time you change tab:
System.Windows.Controls.SelectionChangedEventArgs
contains the old tab inRemovedItems
AddedItems
.Both those properties are an
object[]
.Just look for it in the property window or let the IntelliSense find it for you ;)
尝试在功能区对象上尝试 SelectionChanged 事件。
Try SelectionChanged event on Ribbon Object.