本文介绍了WPF Binding FallbackValue设置为Binding的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!



我正在尝试这样做:

 < Label Content ={Binding SelectedItem.Name,ElementName = groupTreeView,
FallbackValue = {Binding RootGroup.Name}}/>

如果任何人有另一个把戏把它拉下来,那将是很棒的。

解决方案

你正在寻找的东西叫PriorityBinding(#6 on 列表)

p>

(来自文章)

例如

 < TextBox> 
< TextBox.Text>
< PriorityBinding>
< Binding Path =LastNameNonExistantIsAsync =True/>
< Binding Path =FirstNameIsAsync =True/>
< / PriorityBinding>
< /TextBox.Text>
< / TextBox>


Is there a way to have another binding as a fallback value?

I'm trying to do something like this:

<Label Content="{Binding SelectedItem.Name, ElementName=groupTreeView,
                         FallbackValue={Binding RootGroup.Name}}" />

If anyone's got another trick to pull it off, that would be great.

解决方案

What you are looking for is something called PriorityBinding (#6 on this list)

(from the article)

e.g.

<TextBox>
    <TextBox.Text>
        <PriorityBinding>
            <Binding Path="LastNameNonExistant" IsAsync="True" />
            <Binding Path="FirstName" IsAsync="True" />
        </PriorityBinding>
    </TextBox.Text>
</TextBox>

这篇关于WPF Binding FallbackValue设置为Binding的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-07 01:30