diff options
author | nuits.jp <nuits.jp@live.jp> | 2017-06-16 03:47:43 +0300 |
---|---|---|
committer | nuits.jp <nuits.jp@live.jp> | 2017-06-16 03:47:43 +0300 |
commit | e7bc1da8637f11a073a33163d6e8ef2fa1405a37 (patch) | |
tree | 8e3f97d3f69cba6b074cf63b13ff4052ef34471c | |
parent | d5894ccbf751c07fb0e5400d063465629c52afa1 (diff) |
Fixed When a null path is specified by EventArgsParameterPath
-rw-r--r-- | Source/Xamarin/Prism.Forms.Tests/Behaviors/EventToCommandBehaviorFixture.cs | 25 | ||||
-rw-r--r-- | Source/Xamarin/Prism.Forms/Behaviors/EventToCommandBehavior.cs | 4 |
2 files changed, 29 insertions, 0 deletions
diff --git a/Source/Xamarin/Prism.Forms.Tests/Behaviors/EventToCommandBehaviorFixture.cs b/Source/Xamarin/Prism.Forms.Tests/Behaviors/EventToCommandBehaviorFixture.cs index 0c33d39..79e25d7 100644 --- a/Source/Xamarin/Prism.Forms.Tests/Behaviors/EventToCommandBehaviorFixture.cs +++ b/Source/Xamarin/Prism.Forms.Tests/Behaviors/EventToCommandBehaviorFixture.cs @@ -172,6 +172,31 @@ namespace Prism.Forms.Tests.Behaviors Assert.True(executedCommand); } + + [Fact] + public void Command_EventArgsParameterPath_Nested_When_ChildIsNull() + { + dynamic item = new + { + AProperty = "Value" + }; + var executedCommand = false; + var behavior = new EventToCommandBehaviorMock + { + EventName = "ItemTapped", + EventArgsParameterPath = "Item.AProperty", + Command = new DelegateCommand<object>(o => + { + executedCommand = true; + Assert.Null(o); + }) + }; + var listView = new ListView(); + listView.Behaviors.Add(behavior); + behavior.RaiseEvent(listView, new ItemTappedEventArgs(listView, null)); + Assert.True(executedCommand); + } + [Fact] public void Command_CanExecute() { diff --git a/Source/Xamarin/Prism.Forms/Behaviors/EventToCommandBehavior.cs b/Source/Xamarin/Prism.Forms/Behaviors/EventToCommandBehavior.cs index 1d7e8a4..017f66e 100644 --- a/Source/Xamarin/Prism.Forms/Behaviors/EventToCommandBehavior.cs +++ b/Source/Xamarin/Prism.Forms/Behaviors/EventToCommandBehavior.cs @@ -185,6 +185,10 @@ namespace Prism.Behaviors { var propInfo = propertyValue.GetType().GetTypeInfo().GetDeclaredProperty(propertyPathPart); propertyValue = propInfo.GetValue(propertyValue); + if (propertyValue == null) + { + break; + } } parameter = propertyValue; } |