Browse Source

fixes Should_Return_TargetNullValue_When_Value_Is_Null fails

pull/5007/head
Giuseppe Lippolis 6 years ago
parent
commit
8ed53d47be
  1. 15
      src/Markup/Avalonia.Markup/Data/MultiBinding.cs

15
src/Markup/Avalonia.Markup/Data/MultiBinding.cs

@ -48,7 +48,7 @@ namespace Avalonia.Data
/// Gets or sets the binding priority. /// Gets or sets the binding priority.
/// </summary> /// </summary>
public BindingPriority Priority { get; set; } public BindingPriority Priority { get; set; }
/// <summary> /// <summary>
/// Gets or sets the relative source for the binding. /// Gets or sets the relative source for the binding.
/// </summary> /// </summary>
@ -77,12 +77,12 @@ namespace Avalonia.Data
// We only respect `StringFormat` if the type of the property we're assigning to will // We only respect `StringFormat` if the type of the property we're assigning to will
// accept a string. Note that this is slightly different to WPF in that WPF only applies // accept a string. Note that this is slightly different to WPF in that WPF only applies
// `StringFormat` for target type `string` (not `object`). // `StringFormat` for target type `string` (not `object`).
if (!string.IsNullOrWhiteSpace(StringFormat) && if (!string.IsNullOrWhiteSpace(StringFormat) &&
(targetType == typeof(string) || targetType == typeof(object))) (targetType == typeof(string) || targetType == typeof(object)))
{ {
converter = new StringFormatMultiValueConverter(StringFormat, converter); converter = new StringFormatMultiValueConverter(StringFormat, converter);
} }
var children = Bindings.Select(x => x.Initiate(target, null)); var children = Bindings.Select(x => x.Initiate(target, null));
var input = children.Select(x => x.Observable) var input = children.Select(x => x.Observable)
@ -116,8 +116,13 @@ namespace Avalonia.Data
} }
var culture = CultureInfo.CurrentCulture; var culture = CultureInfo.CurrentCulture;
var converted = converter?.Convert(values, targetType, ConverterParameter, culture) object converted;
?? values.ToArray(); if (converter != null)
{
converted = converter.Convert(values, targetType, ConverterParameter, culture);
}
else
converted = values.ToArray();
if (converted == null) if (converted == null)
{ {

Loading…
Cancel
Save