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)
The point to PriorityBinding is to name multiple data bindings in order of most desirable to least desirable. This way if the first binding fails, is empty and/or default, another binding can take it's place.
e.g.
<TextBox> <TextBox.Text> <PriorityBinding> <Binding Path="LastNameNonExistant" IsAsync="True" /> <Binding Path="FirstName" IsAsync="True" /> </PriorityBinding> </TextBox.Text> </TextBox>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With