【发布时间】:2015-11-18 06:30:24
【问题描述】:
例如: 我们需要动态绑定一个 RadioButton Value 属性和 ViewModel 的两个不同属性。
查看模型
public class MyViewModel
{
//Property-1 to bind with RadioButton
public bool Accepted
{
get;
set;
}
//Property-2 to bind with RadioButton
public bool Enable
{
get;
set;
}
//Property to Identify which property should bind with radio button.
public bool Mode
{
get;
set;
}
}
Xaml
<RadioButton Value="{Binding Accepted, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
是否可以动态绑定 Accepted 或 Enable 属性 根据 Mode 属性?
- 提出了一个解决方案是使用 IMultiValueConverter 和 MultiBinding。方法合适吗?
【问题讨论】:
-
您可以控制视图模型吗?为什么不绑定到一个新属性,该属性的值根据 Mode 的值反映 Accepted 或 Enable 的值?