如何在我點擊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