【发布时间】:2013-07-18 21:00:00
【问题描述】:
编辑:
我之前的问题也提到了命令,但正如下面的评论中指出的那样,这是不必要的并且增加了噪音。
这更像是一个 XAML 语法问题,所以它可能是微不足道的。 我想知道如何将字符串文字作为 WPF 中绑定的值传递。
如果从 XAML 的上下文中已经知道该值,是否可以直接将其值直接分配给绑定,而不是使用路径和其他方式? 如果是这样,这种情况下的语法是什么?
<MultiBinding.Bindings>
<!-- First binding, a textbox -->
<Binding RelativeSource="{RelativeSource FindAncestor, AncestorType={x:Type TextBox}}"/>
<!-- Second binding, I want to pass a string as is, for instance, "Description" -->
<!-- The proper syntax for the line below is what I am after -->
<Binding Value="Description"/>
</MultiBinding.Bindings>
【问题讨论】:
-
不能只使用CommandParameter属性吗?
-
CommandParameter 属性已设置为 MultiBinding。为简单起见,我没有发布包含它的整个代码 sn-p。对于可能造成的混乱,我们深表歉意。
标签: wpf string xaml parameters command