如何在我点击BTNAddProvince时获取Treeviewitem?在WPF中获取TreeViewItem
在我的情况下父按钮是stackpanel,我不能得到stackpanel的父(这是获得节点的好办法?)。
任何想法?
<HierarchicalDataTemplate DataType="{x:Type MyService:Region}"
ItemsSource="{Binding Path=ListOfProvinces}">
<StackPanel Orientation="Horizontal">
<TextBlock TextAlignment="Justify" VerticalAlignment="Center" Text="{Binding Path=Name}"/>
<TextBlock TextAlignment="Justify" VerticalAlignment="Center" Text=" H:"/>
<TextBlock TextAlignment="Justify" VerticalAlignment="Center" Text="{Binding Path=NumberOfHotels}"/>
<TextBlock TextAlignment="Justify" VerticalAlignment="Center" Text=" "/>
<Button Name="BTNAddProvince" Height="20" Content="+" Click="BTNAddProvince_Click"></Button>
</StackPanel>
</HierarchicalDataTemplate>
object.ReferenceEquals(parent.GetType的typeof(T))< - 参数类型的方法组不分配给参数类型“对象' 并且你正在使用parent1? – user278618 2010-04-27 16:38:05