DevExpress控件使用交流,DevExpress中国社区Dev联系电话 联系电话:023-68661681

DevExpress WPF 15.2代码示例:如何实现只选中一个项目

来源:   发布时间:2015-12-18   浏览:3587次

本示例演示如何创建这样一个组,即只有一个项目可以被选中。要实现这个功能,要用到一个bar item: BarItemSelector。只要项目位于BarItemSelector中,一个项目选中时,其余项目则自动取消选中。


代码:C#  版本:v15.2.4

<Window
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:dxb="http://schemas.devexpress.com/winfx/2008/xaml/bars" 
        xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors"
        xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core" x:Class="WpfApplication302.MainWindow"
        Title="MainWindow" Height="350" Width="525">
    <Grid>
        <DockPanel>
            <dxb:ToolBarControl Caption="Edit" DockPanel.Dock="Top">
                <dxb:BarItemSelector>
                    <dxb:BarCheckItem Glyph="{dx:DXImage Image=3DColumn_16x16.png}"/>
                    <dxb:BarCheckItem Glyph="{dx:DXImage Image=3DFullStackedArea_32x32.png}"/>
                    <dxb:BarCheckItem Glyph="{dx:DXImage Image=3DClusteredColumn_16x16.png}"/>
                </dxb:BarItemSelector>
                <dxb:BarItemSeparator/>
                <dxb:BarSubItem Content="DropDown">
                    <dxb:BarItemSelector>
                        <dxb:BarCheckItem Content="Option1"/>
                        <dxb:BarCheckItem Content="Option2"/>
                        <dxb:BarCheckItem Content="Option3"/>
                    </dxb:BarItemSelector>
                </dxb:BarSubItem>
            </dxb:ToolBarControl>
            <Grid/>
        </DockPanel>


    </Grid>
</Window>


本站文章除注明转载外,均为本站原创或翻译
欢迎任何形式的转载,但请务必注明出处,尊重他人劳动成果
转载请注明:文章转载自:DevExpress控件中文网 [https://www.devexpresscn.com/]
本文地址:https://www.devexpresscn.com/post/600.html
在线
客服
微信
QQ 电话
023-68661681
返回
顶部