Browse Source
Merge pull request #5310 from jp2masa/indexer-binding
Fixed indexer binding for null target property
pull/5414/head
Steven Kirk
5 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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 |
|
|
public class IndexerBinding : IBinding |
|
|
{ |
|
|
{ |
|
|
@ -24,23 +22,7 @@ namespace Avalonia.Data |
|
|
object anchor = null, |
|
|
object anchor = null, |
|
|
bool enableDataValidation = false) |
|
|
bool enableDataValidation = false) |
|
|
{ |
|
|
{ |
|
|
var mode = Mode == BindingMode.Default ? |
|
|
return new InstancedBinding(Source.GetSubject(Property), Mode, BindingPriority.LocalValue); |
|
|
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."); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|