diff options
-rw-r--r-- | Source/Xamarin/Prism.Forms.Tests/Behaviors/EventToCommandBehaviorFixture.cs | 21 | ||||
-rw-r--r-- | Source/Xamarin/Prism.Forms/Behaviors/EventToCommandBehavior.cs | 4 |
2 files changed, 25 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..38018de 100644 --- a/Source/Xamarin/Prism.Forms.Tests/Behaviors/EventToCommandBehaviorFixture.cs +++ b/Source/Xamarin/Prism.Forms.Tests/Behaviors/EventToCommandBehaviorFixture.cs @@ -172,6 +172,27 @@ namespace Prism.Forms.Tests.Behaviors Assert.True(executedCommand); } + + [Fact] + public void Command_EventArgsParameterPath_Nested_When_ChildIsNull() + { + 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; } |