如何使用MVVM更新组合框更改时的复选框值 [英] How to update checkbox values in view on combo box change using MVVM

查看:81
本文介绍了如何使用MVVM更新组合框更改时的复选框值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个组合框和复选框,当组合时 - 复选框事件被触发复选框应该与check / un-check绑定...我的组合框事件给出了已检查/未选中的数据
,但视图没有得到更新。我怎样才能实现这个目标?

解决方案


我甚至 使用事件,我使用Binding工作。


< pre class ="prettyprint">< StackPanel Margin =" 30">
< ComboBox Margin =" 10" X:名称= QUOT;组合">
< ComboBox.Items>
< ComboBoxItem IsSelected =" True"> False< / ComboBoxItem>
< ComboBoxItem> True< / ComboBoxItem>
< /ComboBox.Items>
< / ComboBox>
< CheckBox x:Name =" ckb"余量= QUOT; 10,50" IsChecked =" {Binding ElementName = combo,Path = SelectedItem.Content}">< / CheckBox>
< / StackPanel>




此致,


Bob


I have a combo-box and checkbox,when the combo-box change event is fired the checkbox should bind with check/un-check...My combo-box event gives the data of checked/unchecked but the view does not gets updated. How can i achieve this?

解决方案

Hi,

I do not even use event, I use Binding to work.

<StackPanel Margin="30">
        <ComboBox Margin="10" x:Name="combo">
            <ComboBox.Items>
                <ComboBoxItem IsSelected="True">False</ComboBoxItem>
                <ComboBoxItem>True</ComboBoxItem>
            </ComboBox.Items>
        </ComboBox>
        <CheckBox x:Name="ckb" Margin="10,50" IsChecked="{Binding ElementName=combo, Path=SelectedItem.Content}"></CheckBox>
    </StackPanel>


Sincerely,

Bob


这篇关于如何使用MVVM更新组合框更改时的复选框值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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