在wpf中的组合框中获取检查的值 [英] getting the checked values in Combobox in wpf

查看:641
本文介绍了在wpf中的组合框中获取检查的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好



我已经在wpf中创建了组合框,此组合框包含复选框,

我的要求是获取组合框中的Checked Checkboxes数据,我认为您可以理解我的英语不好

用于在组合框中创建复选框的示例代码:


Hi to all



I have Created the combobox in wpf ,this Combobox Contains the Checkbox,

my requirement is to get the Checked Checkboxes Data which are in the combobox, i think you can understand my poor english

sample code for creating the checkbox in the Combobox :


<ComboBox Name="cmb" Margin="5" Height="23" Canvas.Left="98" Canvas.Top="251" Width="163" SelectionChanged="cmb_SelectionChanged">
                      <ComboBox.ItemTemplate>
                       <DataTemplate>
                       <StackPanel Orientation="Horizontal">
                           <CheckBox Margin="5" IsChecked="{Binding IsVisited}" Checked="CheckBox_Checked"/>
                           <TextBlock Margin="5" Text="{Binding CityName}"/>
                       </StackPanel>
                 </DataTemplate>
              </ComboBox.ItemTemplate>
            </ComboBox>




因此,我需要从组合框中检索已检查"数据,因此请尝试解释概念",并提出想法




so i Need to retrive the Checked data from the Combobox,so please try to explain the Concept and giove me idea

推荐答案

cmbfilter is the combobox name, just typecast it...
 
string cmbvalue="";
System.Windows.Controls.ComboBoxItem curItem=((System.Windows.Controls.ComboBoxItem)Cmbfilter.SelectedItem);
cmbvalue=curItem.Content;



希望这对您有帮助...

-
AJ



Hope this helped...

--
AJ


您具有一个IsVisited属性的绑定.组合框数据项中该属性的值应指示是否选中了该复选框(您可能必须将绑定的模式设置为TwoWay).
You have a binding to a IsVisited property. The value of that property in the combobox data items should indicate whether the checkbox is checked or not (you may have to set the binding''s mode to TwoWay).


这篇关于在wpf中的组合框中获取检查的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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