台灣最大程式設計社群網站
∣
免費加入會員
∣登入
∣回首頁∣
您好
線上人數
1289
會員總數:
246219
討論主題:
189783
討論區
程式下載/上傳
科技新聞
專欄文章
會員中心
加值服務
外包接案
求職求才
登入
登出
歡迎您
免費
加入會員
討論區選單
新手必讀
我要提問!!
討論區
個人討論區
我的關注主題
我的黑名單
討論區EP英雄榜
專家等級說明
討論區常見問題
兌換發問點數QP
扣點申請加值服務
申請版主
開發工具
ASP
ASP.NET
C#
VB.NET
VB6
C/C++
PHP
Java
Java Script/ Node.js
AJAX / JSON / jQuery
其他語言
行動裝置開發
Android APP 開發
iOS APP/ swift 開發
Windows Phone APP
資料庫
ACCESS
MS SQL
MySQL
Oracle
其他DB
多媒體 / 網管
CSS/HTML5/Bootstarp
影像處理
office VBA / WinOS
Windows 伺服器
Linux / Unix
網管 / 資安 / VM
硬體 / 週邊 / 其他
綜合
求職求才
外包接案
心情甘苦談
網站經營 / 合夥 / 證照
建言 / 公告
文章區
專欄文章
科技新聞
Blog精華文章
討論區列表
>>
CSS/HTML5/Bootstarp
>> TreeViewDragDropTarget 沒有功能
[]
[
我要回覆
]
TreeViewDragDropTarget 沒有功能
價值 : 200 QP
點閱數:1410 回應數:0
樓主
fet
0
46
1368
83
發送站內信
在TreeView中,開放DragDrop功能
在使用TreeViewDragDropTarget後,還是無法位置交換
將 a2 拖到 a3 (兩個位置交換)
找了一天相關網站及資料,始終無法完成,網路上的資料都是以ListBox為主
沒有提供TreeView之範例
請各位前輩指教一下
謝謝
XML檔
<?xml version="1.0" encoding="utf-8" ?> <root> <node name="a1" Text="a1"> <node name="a2" Text="a2" /> <node name="a3" Text="a3" /> <node name="a4" Text="a4" /> </node> </root>
XAML
<UserControl xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls" xmlns:common="clr-namespace:System.Windows;assembly=System.Windows.Controls" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:toolkit="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Toolkit" xmlns:mswindows="clr-namespace:Microsoft.Windows;assembly=System.Windows.Controls.Toolkit" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" x:Class="HR_Organize_Constitute.MainPage" Width="900" Height="500" mc:Ignorable="d"> <Grid x:Name="LayoutRoot" Background="White"> <toolkit:TreeViewDragDropTarget x:Name="TreeViewDragDrop" mswindows:DragDrop.AllowDrop="True"> <controls:TreeView x:Name="TreeView1" Margin="0,0,11,0" Width="822" Height="427"> <controls:TreeView.ItemTemplate> <common:HierarchicalDataTemplate ItemsSource="{Binding Children}"> <StackPanel> <TextBlock Text="{Binding Text}" /> </StackPanel> </common:HierarchicalDataTemplate> </controls:TreeView.ItemTemplate> </controls:TreeView> </toolkit:TreeViewDragDropTarget> </Grid> </UserControl>
vb
Partial Public Class MainPage Inherits UserControl Public Sub New() InitializeComponent() End Sub Private Sub MainPage_Loaded(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles Me.Loaded Dim XmlRoot As System.Xml.Linq.XElement = System.Xml.Linq.XElement.Load("XML/Test1.xml") Dim result = GetLoadData(XmlRoot) TreeView1.ItemsSource = result End Sub Public Function GetLoadData(ByVal root As System.Xml.Linq.XElement) As List(Of clsTreeViewModel) If root Is Nothing Then Return Nothing Dim result = From n In root.Elements("node") _ Select New clsTreeViewModel With {.Name = n.Attribute("name").Value, _ .Text = n.Attribute("Text").Value, _ .Children = getLoadData(n)} Return result.ToList End Function Public Class clsTreeViewModel Private _Name As String Private _Text As String Private _Children As List(Of clsTreeViewModel) Public Property Name() As String Get Return Me._Name End Get Set(ByVal value As String) Me._Name = value End Set End Property Public Property Text() As String Get Return Me._Text End Get Set(ByVal value As String) Me._Text = value End Set End Property Public Property Children() As List(Of clsTreeViewModel) Get Return Me._Children End Get Set(ByVal value As List(Of clsTreeViewModel)) Me._Children = value End Set End Property End Class End Class
本篇文章發表於2010-03-18 08:35
目前尚無任何回覆
回覆
如要回應,請先
登入
.
|
網站導覽
|
網站介紹
|
4P點數說明
|
電子報
|
小舖活動
|
大事紀
|
廣告刊登
|
常見問題
|
聯絡我們
|
版權所有 ©copyright 2000 All Rights Reserved