如何在WPF中提供字符串文字值作为绑定

Lou*_*uis 2 string parameters wpf xaml command

编辑:

我之前的问题也提到了命令,但正如下面的评论所指出的那样,它是不必要的并且增加了噪音.


这更像是一个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>
Run Code Online (Sandbox Code Playgroud)

H.B*_*.B. 10

它的

<Binding Source="Description"/>
Run Code Online (Sandbox Code Playgroud)

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

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