RibbonApplicationMenuItem 有错误的 CurrentItem?
我有一个带有相同类型子项的 RibbonApplicationMenuItem 。子项是通过代码添加的。
选择 RibbonApplicationMenuItem 后,处理单击事件时会显示错误的 currentItem。
CurrentItem 始终是我的 RibbonApplicationMenuItems 集合中的第一个元素。
private void ApplicationOpenPileList_Click(object sender, RoutedEventArgs e) {
RibbonApplicationMenuItem SourceApplicationMenu = null;
RibbonApplicationMenuItem SenderApplicationMenu = null;
Pile currentPile = null;
if (e.OriginalSource != null) {
if (sender is RibbonApplicationMenuItem && e.OriginalSource is RibbonApplicationMenuItem) {
SenderApplicationMenu = sender as RibbonApplicationMenuItem;
SourceApplicationMenu = e.OriginalSource as RibbonApplicationMenuItem;
}
}
}
SourceApplicationMenu 包含单击的 MenuItem,但我连接的对象丢失。 SenderApplicationMenu 包含相应的 ParentMenuItem,其属性名为 CurrentItem。
事件在主元素的功能区窗口的 XAML 代码中分配:
<ribbon:Ribbon.ApplicationMenu>
<ribbon:RibbonApplicationMenu SmallImageSource="Resources\Icons\Scanner.ico">
<ribbon:RibbonApplicationMenuItem Header="Neu" ImageSource="Resources\Icons\report_add.png"/>
<ribbon:RibbonApplicationMenuItem Header="Öffnen" ImageSource="Resources\Icons\open_folder.png" Name="ApplicationOpenPileList" Click="ApplicationOpenPileList_Click" />
<ribbon:RibbonApplicationMenuItem Header="Dokumententypen" ImageSource="Resources\Icons\application_form.png" DisplayMemberPath="Name" Click="RibbonApplicationMenuItem_Click" />
<ribbon:RibbonApplicationMenuItem Header="Schließen" ImageSource="Resources\Icons\cross.png"/>
</ribbon:RibbonApplicationMenu>
</ribbon:Ribbon.ApplicationMenu>
在这种情况下,CurrentItem 始终包含具有相应对象的第一个 SubItem。 有什么想法吗?
I've got an RibbonApplicationMenuItem with SubItems of the same Kind. The SubItems are added by Code.
After selecting a RibbonApplicationMenuItem the wrong currentItem is shown while handling the click event.
CurrentItem is always the first element in in my Collection of RibbonApplicationMenuItems.
private void ApplicationOpenPileList_Click(object sender, RoutedEventArgs e) {
RibbonApplicationMenuItem SourceApplicationMenu = null;
RibbonApplicationMenuItem SenderApplicationMenu = null;
Pile currentPile = null;
if (e.OriginalSource != null) {
if (sender is RibbonApplicationMenuItem && e.OriginalSource is RibbonApplicationMenuItem) {
SenderApplicationMenu = sender as RibbonApplicationMenuItem;
SourceApplicationMenu = e.OriginalSource as RibbonApplicationMenuItem;
}
}
}
SourceApplicationMenu contains the clicked MenuItem, but my connected Object is missing.
SenderApplicationMenu contains the corrospondig ParentMenuItem whith a property called CurrentItem.
The Event is assigned in XAML Code of the ribbonwindow for the main element:
<ribbon:Ribbon.ApplicationMenu>
<ribbon:RibbonApplicationMenu SmallImageSource="Resources\Icons\Scanner.ico">
<ribbon:RibbonApplicationMenuItem Header="Neu" ImageSource="Resources\Icons\report_add.png"/>
<ribbon:RibbonApplicationMenuItem Header="Öffnen" ImageSource="Resources\Icons\open_folder.png" Name="ApplicationOpenPileList" Click="ApplicationOpenPileList_Click" />
<ribbon:RibbonApplicationMenuItem Header="Dokumententypen" ImageSource="Resources\Icons\application_form.png" DisplayMemberPath="Name" Click="RibbonApplicationMenuItem_Click" />
<ribbon:RibbonApplicationMenuItem Header="Schließen" ImageSource="Resources\Icons\cross.png"/>
</ribbon:RibbonApplicationMenu>
</ribbon:Ribbon.ApplicationMenu>
In this case CurrentItem always contains the first SubItem with the correspondig object.
Any Ideas ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题很简单。
SubItems 没有 Click 事件处理程序,因此事件被路由到上层处理程序。
我现在已经为每个项目实现了处理程序,一切都很好。
Problem was quite simple.
The SubItems hasn't got a Click Event handler, so the events were routed to the upper handler.
I've now implement the handler for each Item and everything is fine.