如何在列表框中选中单个复选框 [英] How do I select single check box inside the listbox
本文介绍了如何在列表框中选中单个复选框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在wpf项目中工作,因为我有一个列表框内的复选框。我想要复选框中的单一选择。请任何一个帮助。这是我的代码
I work in wpf project in that i have a checkbox inside of it one listbox. i want single selection in checkbox .Please any one help. This is my code
<ListBox Name="lstbxFieldName" HorizontalContentAlignment="Left" Height="170" Width="320" Style="{StaticResource lstBoxStyle}" TabIndex="4">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" Margin="20,0,0,0" ScrollViewer.VerticalScrollBarVisibility="Visible">
<CheckBox Name="chkuser" Tag="{Binding FieldValue}" Content="{Binding FieldName}" HorizontalAlignment="Left" Margin="5,5,0,0"/>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
推荐答案
简单的解决方案是使用RadioButton
。
有没有这样的直接方法在CheckBox
中进行单一选择。你想到了一些工作。那么,为什么要浪费时间。只需使用RadioButton
。
Simple solution is to useRadioButton
.
There is no such direct method to do single selection inCheckBox
. You have think of some work around. So, why wasting time. Just useRadioButton
.
这篇关于如何在列表框中选中单个复选框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文