Null value in expression ''." - In EventTriggerBehavior and DataTriggerBehavior
See original GitHub issueIssue #17 was already about this, but the ‘solution’ (There wasn’t really a solution posted) mentioned there doesn’t work for me.
I still get the following warning during execution: [Binding] Error in binding to "Avalonia.Xaml.Interactions.Core.InvokeCommandAction"."Command": "Null value in expression ''." (Avalonia.Xaml.Interactions.Core.InvokeCommandAction #12001237)
The code does work (The double tap event triggers the command successfully), but emits this warning for each of the event triggers during runtime. I have exactly the same problem with a DataTrigger, but that one refuses to work at all.
Take this simple example:
Relevant XAML namespaces, for your convenience
xmlns:i="clr-namespace:Avalonia.Xaml.Interactivity;assembly=Avalonia.Xaml.Interactivity"
xmlns:ia="clr-namespace:Avalonia.Xaml.Interactions.Core;assembly=Avalonia.Xaml.Interactions"
XAML
<TextBlock Name="driveLabel" Text="{Binding DisplayName}">
<i:Interaction.Behaviors>
<ia:EventTriggerBehavior EventName="DoubleTapped" SourceObject="{Binding #driveLabel}">
<ia:InvokeCommandAction CommandParameter="{Binding}" Command="{Binding DataContext.OpenDriveCommand, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}" />
</ia:EventTriggerBehavior>
</i:Interaction.Behaviors>
</TextBlock>
C# code
public ReactiveCommand<MyViewModel, Unit> OpenDriveCommand { get; }
public MyConstructor()
{
this.OpenDriveCommand = ReactiveCommand.Create<MyViewModel, Unit>(this.openDrive);
}
private Unit openDrive(MyViewModel viewModel)
{
// Do stuff
return Unit.Default;
}
So setting ‘Unit’ as the return type of the command, does not get rid of this warning. Does anybody know how to get rid of this warning?
I also would like to ask if if someone knows what would be wrong with my DataTrigger. It emits the same warning as the EventTriggerBehavior, only then with DataTriggerBehavior as type, and it doesn’t do anything at all. The image source is supposed to differ per directory entry type, but instead nothing is shown now.
<Image Height="19" Margin="0 0 5 0" Name="image">
<i:Interaction.Behaviors>
<ia:DataTriggerBehavior Binding="{Binding Type}" ComparisonCondition="Equal" Value="{x:Static models:DirectoryEntryType.Directory}">
<ia:ChangePropertyAction TargetObject="{Binding #image}" PropertyName="Source" Value="/Assets/Icons/folder_closed.ico"/>
</ia:DataTriggerBehavior>
<ia:DataTriggerBehavior Binding="{Binding Type}" ComparisonCondition="Equal" Value="{x:Static models:DirectoryEntryType.File}">
<ia:ChangePropertyAction TargetObject="{Binding #image}" PropertyName="Source" Value="/Assets/Icons/cpp.ico"/>
</ia:DataTriggerBehavior>
</i:Interaction.Behaviors>
</Image>
Issue Analytics
- State:
- Created 3 years ago
- Comments:12
Top GitHub Comments
@calmcl1 I still have the exact same problem (Also on the new package version). No solution, unfortunately…
any news on that? im facing the same issue with a binding in control template