C1treeView的SelectedItem在ItemClick事件下为空
Xaml:<c1:C1TreeView Grid.Row="1" Grid.Column="0" Grid.RowSpan="2" x:Name="C1TreeView1"Background="#E6F4FB" Header="{Binding Eattribute1}"
ShowLines="True"ItemClick="C1TreeView1_ItemClick_1">
<c1:C1TreeView.ItemTemplate>
<HierarchicalDataTemplateItemsSource="{Binding QmInspectionVornr}" >
<StackPanel Orientation="Horizontal">
<Label Content="{Binding Eattribute1}" MinHeight="30" VerticalContentAlignment="Center"VerticalAlignment="Center" Padding="4 0 4 0"/>
</StackPanel>
</HierarchicalDataTemplate>
</c1:C1TreeView.ItemTemplate>
</c1:C1TreeView>
后台:
private void C1TreeView1_ItemClick_1(object sender, SourcedEventArgs e)
{
C1TreeView vC1TreeView = sender as C1TreeView;
if (vC1TreeView.SelectedItem != null)
{
//QMInspectionEntity
QMInspectionEntity vQMInspectionEntity = (QMInspectionEntity)vC1TreeView.SelectedItem.DataContext;
}
}
问题:
C1TreeView数据绑定为IList
vC1TreeView.SelectedItem 一直为null 我需要拿到C1TreeView当前点击行所绑定的数据
做了一个小demo,请参考附件,我这里测试可以获取到选择的内容,你看看和你那边的情况有何不同
页:
[1]