将代码绑定转换为XAML

时间:2014-03-21 18:35:43

标签: c# silverlight xaml

难以将以下代码转换为XAML:

var b2 = new Binding("Toggled") { RelativeSource = new RelativeSource(RelativeSourceMode.Self) };
button.SetBinding(ButtonBase.CommandParameterProperty, b2);

尝试:

CommandParameter="{Binding Toggled, RelativeSource=Self}" 

但这不起作用,"相对来源不支持从字符串转换"

1 个答案:

答案 0 :(得分:0)

尝试:

CommandParameter="{Binding Toggled, RelativeSource={RelativeSource Self}}" 

See this page in the MSDN

相关问题