[Silverlight] 無碼做出兩個Listbox資料互相拖曳
2010/11/18
朋友問的問題…
才發現…
只要善用社群力量還蠻簡單的…
今天介紹如何使用 Silverlight 4 Toolkit 就可以無碼就可以做到這效果 …
首先你得先去 http://silverlight.codeplex.com/ 下載 Lib ..
解完壓縮後…
在專案中引入 Bin\System.Windows.Controls.Toolkit.dll
這樣專案檔會長這樣..
就來看XAML檔的部分…
<UserControl x:Class="DragSample.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" d:DesignHeight="300" d:DesignWidth="400" xmlns:toolKit="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Toolkit" xmlns:System="clr-namespace:System;assembly=mscorlib"> <Grid x:Name="LayoutRoot" Background="White" Loaded="LayoutRoot_Loaded"> <toolKit:ListBoxDragDropTarget AllowDrop="True" Height="276" HorizontalAlignment="Left" Margin="12,12,0,12" Name="lbDropTarget" Width="168"> <ListBox Height="257" x:Name="lbLeft" Width="143"> <System:String>Downmud</System:String> <System:String>當麻許</System:String> <System:String>超自然現象研究社</System:String> <System:String>上條當麻</System:String> </ListBox> </toolKit:ListBoxDragDropTarget> <toolKit:ListBoxDragDropTarget Height="276" AllowDrop="True" HorizontalAlignment="Left" Margin="204,12,0,12" Name="lbDropSoruce" Width="168" > <ListBox Height="257" Name="lbRight" Width="143" /> </toolKit:ListBoxDragDropTarget> </Grid> </UserControl>
看一下畫面配置..
我用ToolKit 中的元件 ListBoxDragDropTarget 去包覆住 ListBox 這樣兩邊資料就可以進行拖曳了..
沒錯..就是這麼簡單就可以做到這效果…
不過注意:
在UserControl 中記得要加入
xmlns:toolKit="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Toolkit"
執行效果:
案例預覽:
讚一下:
案例下載:
標籤:
Silverlight
|
This entry was posted on 下午6:51
and is filed under
Silverlight
.
You can follow any responses to this entry through
the RSS 2.0 feed.
You can leave a response,
or trackback from your own site.
訂閱:
張貼留言 (Atom)
0 意見:
張貼留言