5

EDIT:

My former question also referred to commands, but as pointed out in a comment below, it was unnecessary and added noise.


This is more a XAML syntax question, so it is probably trivial. I would like to know how to pass a string literal as a value for a binding in WPF.

If the value is already known from the context in XAML, may its value simply be directly assigned to the binding, instead of using paths and other means? If so, what would the syntax be in that case?

<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>
4

1 回答 1

14

它是

<Binding Source="Description"/>

Source可以是任何类型,因此在被解释为字符串的属性语法中,如果没有Path指定绑定的值是源。

这也是一个多重绑定,我不会谈论命令参数,因为这与此事无关......

于 2013-07-18T21:03:43.337 回答