I am trying to bind to a TreeView with ReactiveUI in WPF, but nothing is being displayed. Can anyone tell me where I am going wrong, or give me some advice on how to debug it?
Binding in View constructor:
this.OneWayBind(ViewModel,
vm => vm.NonTableItemCommentsViewModels,
view => view.CommentTree.ItemsSource);
Xaml:
<TreeView Name="CommentTree" ItemsSource="{Binding}">
<TreeView.Resources>
<!-- Template for Items -->
<HierarchicalDataTemplate DataType="{x:Type viewModels:NonTableItemCommentsViewModel}"
ItemsSource="{Binding Path=Comments, Mode=OneWay}">
<TextBlock Text="{Binding Path=ItemId, Mode=OneWay}" />
</HierarchicalDataTemplate>
<!-- Template for Comments -->
<DataTemplate DataType="{x:Type viewModels:CommentViewModel}">
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Path=Text, Mode=OneWay}"
Margin="3,0" />
<TextBlock Text="{Binding Path=Author, Mode=OneWay}"
Margin="3,0" />
</StackPanel>
</DataTemplate>
</TreeView.Resources>
</TreeView>
Items
and Comments
are both ObservableCollections.