0
<sdk:TreeView x:Name="tvPageManager" SelectedItemChanged="tvPageManager_SelectedItemChanged" Style="{StaticResource PageManagerStyle}"
ScrollViewer.HorizontalScrollBarVisibility="Hidden" ScrollViewer.VerticalScrollBarVisibility="Auto">
<sdk:TreeView.ItemTemplate>
<sdk:HierarchicalDataTemplate ItemsSource="{Binding KeyPoints, Mode=TwoWay}">
<StackPanel Orientation="Horizontal">
<ToolTipService.ToolTip>
<ToolTip Content="{Binding PageName}" Style="{StaticResource ToolTipStyle}"/>
</ToolTipService.ToolTip>
<Image x:Name="imgPageIcon" Source="{Binding PageIconImage}" Style="{StaticResource PageIconStyle}" MouseLeftButtonDown="imgPageIcon_MouseLeftButtonDown" Tag="{Binding BurstPageId, Mode=TwoWay}" />
<TextBlock x:Name="tbkLiteralTextPage" Text="Page " Style="{StaticResource PageNameLiteralTextBlockStyle}" />
<TextBox x:Name="tbPageName" Text="{Binding PageName, Mode=TwoWay}" Style="{StaticResource PageNameTextBoxStyle}" TextChanged="tbPageName_TextChanged" />
</StackPanel>
<sdk:HierarchicalDataTemplate.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<Image x:Name="imgKeypointIcon" Source="../Assets/Images/bullet_yellow.png" Style="{StaticResource KeypointIconStyle}"/>
<TextBlock x:Name="tbkKeypointTitle" Text="{Binding Title, Mode=TwoWay}" Style="{StaticResource KeypointNameTextBlockStyle}" />
<StackPanel x:Name="spnlMoveImages" Orientation="Horizontal" HorizontalAlignment="Right" Width="30">
<Image x:Name="imgMoveUp" Source="../Assets/Images/up_arrow.png" Style="{StaticResource MoveIconsStyle}" MouseLeftButtonDown="imgMoveUp_MouseLeftButtonDown" Tag="{Binding KeyPointId}"/>
<Image x:Name="imgMoveDn" Source="../Assets/Images/down_arrow.png" Style="{StaticResource MoveIconsStyle}" MouseLeftButtonDown="imgMoveDn_MouseLeftButtonDown" Tag="{Binding KeyPointId}"/>
</StackPanel>
</StackPanel>
</DataTemplate>
</sdk:HierarchicalDataTemplate.ItemTemplate>
</sdk:HierarchicalDataTemplate>
</sdk:TreeView.ItemTemplate>
</sdk:TreeView>
對於上面的XAML,我需要以編程方式知道,這是選定的節點還是葉?Silverlight 4:TreeView/HierarchicalDataTemplate /獲取選定的節點/葉問題
對不起,不夠具體。其實我需要從c#代碼中選擇一個節點。 場景:我在運行時插入/刪除子節點,此時集合發生更改(樹視圖已綁定到此; this.tvPageManager.ItemsSource = burst.BurstPages)。因此,選擇(選定焦點)在樹視圖中更改。我需要在添加/刪除子節點成功完成後再次設置它。 –
啊,你想編寫一個遞歸搜索,然後在所需的樹節點上將IsSelected屬性設置爲true。識別目標節點的方法是什麼?標記值?文本? –