I'm creating a WPF app using MVVMLight. I defined a ListView inside a TabControl DataTemplate, like so:
<TabControl.ContentTemplate>
<DataTemplate>
<ListView ItemsSource="{Binding Builds}"
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
SelectedItem="{Binding SelectedBuild,
Mode=TwoWay}"
SelectionMode="Single">
<i:Interaction.Triggers>
<i:EventTrigger EventName="MouseDoubleClick">
<i:InvokeCommandAction Command="{Binding BuildSelectedCommand}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</ListView>
</DataTemplate>
</TabControl.ContentTemplate>
but XAML Designer returns this error (preventing the load of the designer preview):
XamlObjectWriterException: Collection property 'System.Windows.Controls.ListView'.'Triggers' is null.
at System.Xaml.XamlObjectWriter.WriteGetObject()
at System.Xaml.XamlWriter.WriteNode(XamlReader reader)
at System.Windows.FrameworkTemplate.LoadTemplateXaml(XamlReader templateReader, XamlObjectWriter currentWriter)
my Command is defined like so in my ViewModel:
private RelayCommand _buildSelectedCommand;
public RelayCommand BuildSelectedCommand => _buildSelectedCommand ??
(_buildSelectedCommand = new RelayCommand(BuildSelectedAction));
This is the first time I'm seeing this error, and it's happening only at design time, building and runtime it's fine. Removing the i:Interaction.Triggers fix the problem, but I need the DoubleClick event on the list.
If you ask why I didn't add the trigger at the ListItem level, it's because I have to set a property on the ViewModel binding the TabControl Datatemplate, not the ListItem ViewModel.
Thanks a lot for the help!