To do this, you actually need to affect the ItemContainerStyle
for the TreeView
. This sets the style for the ItemContainer (TreeViewItem
) that is generated for each node of the Tree.
<TreeView HorizontalAlignment="Left" Height="319" VerticalAlignment="Top" Width="517" ItemsSource="{Binding Tree}">
<TreeView.ItemTemplate>
<!-- Leave this the same, except for the IsEnabled binding on the button -->
</TreeView.ItemTemplate>
<TreeView.ItemContainerStyle>
<Style TargetType="{x:Type TreeViewItem}">
<Setter Property="IsEnabled" Value="{Binding IsEnabled}"/>
</Style>
</TreeView.ItemContainerStyle>
</TreeView>