Browse Source
Fixed indexer binding for null target property.
pull/5310/head
José Pedro
5 years ago
No known key found for this signature in database
GPG Key ID: B8247B9301707B83
1 changed files with
2 additions and
20 deletions
-
src/Avalonia.Base/Data/IndexerBinding.cs
|
|
|
@ -1,6 +1,4 @@ |
|
|
|
using System; |
|
|
|
|
|
|
|
namespace Avalonia.Data |
|
|
|
namespace Avalonia.Data |
|
|
|
{ |
|
|
|
public class IndexerBinding : IBinding |
|
|
|
{ |
|
|
|
@ -24,23 +22,7 @@ namespace Avalonia.Data |
|
|
|
object anchor = null, |
|
|
|
bool enableDataValidation = false) |
|
|
|
{ |
|
|
|
var mode = Mode == BindingMode.Default ? |
|
|
|
targetProperty.GetMetadata(target.GetType()).DefaultBindingMode : |
|
|
|
Mode; |
|
|
|
|
|
|
|
switch (mode) |
|
|
|
{ |
|
|
|
case BindingMode.OneTime: |
|
|
|
return InstancedBinding.OneTime(Source.GetObservable(Property)); |
|
|
|
case BindingMode.OneWay: |
|
|
|
return InstancedBinding.OneWay(Source.GetObservable(Property)); |
|
|
|
case BindingMode.OneWayToSource: |
|
|
|
return InstancedBinding.OneWayToSource(Source.GetSubject(Property)); |
|
|
|
case BindingMode.TwoWay: |
|
|
|
return InstancedBinding.TwoWay(Source.GetSubject(Property)); |
|
|
|
default: |
|
|
|
throw new NotSupportedException("Unsupported BindingMode."); |
|
|
|
} |
|
|
|
return new InstancedBinding(Source.GetSubject(Property), Mode, BindingPriority.LocalValue); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|