0

I can't figure out how to defined the fallback values of:

  • A list, e.g. for a ComboBox ItemsSource
  • A command, e.g. for a Button Command
  • Other complex objects

I tried {x:Null} but doesn't seem to work:

<ComboBox ItemsSource="{Binding Path=Regions, FallbackValue={x:Null}}"
goul
  • 813
  • 1
  • 13
  • 32
  • 1
    When you say "doesn't seem to work", what exactly do you mean? Did you record somehow what the output is, when the binding does not resolve and FallbackValue is called? – Keyur PATEL Jun 13 '17 at 07:36
  • I did, this is what I have as warning raised: System.Windows.Data Information: 10 : Cannot retrieve value using the binding and no valid fallback value exists; using default instead. BindingExpression:Path=DeleteCommand; DataItem=null; target element is 'TextBoxCombo' (Name='CurrentUserControl'); target property is 'DeleteCommand' (type 'ICommand') – goul Jun 13 '17 at 08:49
  • Well, your example is for ICommands, I am not sure if FallbackValue of null would work on buttons, since they are always enabled by default. However, according to this answer here: [Why is a button enabled if the Command binding resolves to null?](https://stackoverflow.com/a/18465023/6741868), you can set null using a binding fallback value. For 'Other complex objects' such as your ComboBox ItemsSource, the same method would work. – Keyur PATEL Jun 13 '17 at 09:10

0 Answers0