I'm trying to bind a tooltipOpening Event handler to a TreeView Item in XAML. However, the g.i.cs file that gets generated instead binds the Event Handler to a button and when the window is initialized I get an invalid cast exception. Visual Studio is binding the tool tip to a label that follows the treeview definition and not to the treeview item.
this is the XAML code
Code:
<StackPanel Grid.Column="1">
<Label x:Name="ISLLabel" Content="ISLs" Margin="0,0,45,0" FontWeight="Bold" Height="67"/>
<TreeView x:Name="ISLTreeView" Height="auto" Background="GhostWhite"
BorderThickness="0" Width="auto"
ItemsSource="{Binding}"
ScrollViewer.VerticalScrollBarVisibility="auto">
<TreeView.ItemContainerStyle>
<Style TargetType="{x:Type TreeViewItem}">
<Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay}" />
<Setter Property="ToolTip">
<Setter.Value>
<ToolTip ToolTipOpening="ISL_TreeViewTipOpening"></ToolTip>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter Property="FontWeight" Value="Bold" />
</Trigger>
</Style.Triggers>
</Style>
</TreeView.ItemContainerStyle>
</TreeView>
<Label x:Name="NeighborLabel" Content="Neighbors List"></Label>
<TreeView x:Name="NeighborsTreeView" Height="Auto"
Background="GhostWhite" BorderThickness="0" Width="auto"
ItemsSource="{Binding}"
ScrollViewer.VerticalScrollBarVisibility="auto">
</TreeView>
this is from the auto-generated g.i.cs file for the window
Code:
#line 104 "..\..\..\SwitchBrowser.xaml"
this.NeighborLabel.ToolTipOpening += new System.Windows.Controls.ToolTipEventHandler(this.ISL_TreeViewTipOpening);