RibbonGallery选中的项目被卡住了 [英] RibbonGallery selected item stucked

查看:69
本文介绍了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选中的项目被卡住了的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆