RibbonGallery选中的项目被卡住了

编程入门 行业动态 更新时间:2024-10-23 01:41:45
本文介绍了RibbonGallery选中的项目被卡住了的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

嗨! $ 在RibbonSplitButton中我有一个 RibbonGallery ,它有一个可观察集合的ItemsSource。 当点击下拉列表列表中的任何项目时,它会触发一个窗口显示。 问题是,当我关闭窗口时,打开再次下拉,之前选择的项目一直被选中,使我无法通过点击它触发窗口外观。 如果我更新observablecollection,下拉列表会更新,并且删除选择,但效率非常低。

如何删除选择以不同的方式? 提前致谢!

解决方案

您好 oolin, 您可以尝试以下方法。 您可以添加IsSelected属性在您的模型中将绑定到RibbonGallery。

private string _label; public bool IsSelected { get { return _isSelected; } 设置 { if(_isSelected!= value) { _isSelected = value; OnPropertyChanged(new PropertyChangedEventArgs(" IsSelected")); } } }

并在RibbonGallery.GalleryItemStyle中绑定IsSelected属性。

< ribbon:RibbonGallery.GalleryItemStyle> < Style TargetType =" ribbon:RibbonGalleryItem"> //< Setter Property =" IsSelected"值=" {Binding IsSelected}" /> < Setter Property =" IsSelected" Value =" {Binding IsSelected,Converter =}" /> < / Style> < / ribbon:RibbonGallery.GalleryItemStyle>

最后,使用转换器设置Property =" IsSelected"假(总是)。然后,之前选择的项目将不会被选中。 您可以参考样本: 如何添加图库到我的功能区 $ 此外,你可以使用 RibbonButton 下划线以触发显示的窗口。 最好的问候, Yong Lu

Hi! Inside a RibbonSplitButton I have a RibbonGallery, which has an ItemsSource of an observablecollection. When any item on the dropdown list is clicked, it triggers a window to be displayed. The problem is, when I close the window, and open the dropdown again, the previously selected item keeps being selected, making it unable for me to trigger the windows appearence by clicking on it. If I update the observablecollection, the dropdown is updated, and the selection is removed, but its pretty inefficient.

Any ideas how to remove the selection in a different fashion? Thanks in advance!

解决方案

Hi oolin, You may can try the following method. You can add a IsSelected property in your model which will bind to the RibbonGallery.

private string _label; public bool IsSelected { get { return _isSelected; } set { if (_isSelected != value) { _isSelected = value; OnPropertyChanged(new PropertyChangedEventArgs("IsSelected")); } } }

And binding the IsSelected property in your RibbonGallery.GalleryItemStyle.

<ribbon:RibbonGallery.GalleryItemStyle> <Style TargetType="ribbon:RibbonGalleryItem"> //<Setter Property="IsSelected" Value="{Binding IsSelected}" /> <Setter Property="IsSelected" Value="{Binding IsSelected,Converter=}" /> </Style> </ribbon:RibbonGallery.GalleryItemStyle>

Finally, use a Converter set the Property="IsSelected" to false(always). Then, the previously selected item will not keep being selected. You can refer the sample:How do I add Galleries to my Ribbon Besides, You can use the RibbonButton to trigger a window to be displayed. Best Regards, Yong Lu

更多推荐

RibbonGallery选中的项目被卡住了

本文发布于:2023-11-23 18:36:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1622477.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:卡住了   项目   RibbonGallery

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!