I have a tree view that I'm binding to with some custom viewmodels. The viewmodels are in an ObservableCollection
and inherit ViewModelBase
which inherits INotifyPropertyChanged
.
It compiles and run fine, but in the designer I'm getting the error:
"DataTemplate.DataType cannot be type object
Parameter name: value"
My XAML is:
<TreeView Grid.Row="1" ItemsSource="{Binding ResultsTree}" SelectedItemChanged="TreeView_OnSelectedItemChanged">
<TreeView.Resources>
<HierarchicalDataTemplate DataType="{x:Type local:TreeViewItemViewModel}" ItemsSource="{Binding Path=Children}">
<StackPanel Orientation="Horizontal">
<CheckBox IsChecked="{Binding IsChecked}"/>
<TextBlock Text="{Binding Text}"/>
</StackPanel>
</HierarchicalDataTemplate>
<DataTemplate DataType="{x:Type local:CorrectionAndFreqViewModel}">
<StackPanel Orientation="Horizontal" ToolTip="{Binding AmbientText}">
<Rectangle Width="20" Height="5" Fill="{Binding LineColor, Converter={StaticResource ColorToSolidColorBrushValueConverter}}"></Rectangle>
<CheckBox IsChecked="{Binding IsChecked}"/>
<TextBlock Text="{Binding Text}"/>
</StackPanel>
</DataTemplate>
</TreeView.Resources>
</TreeView>
The properties window says its an Object too, but I have no idea why:
Any ideas?