zoukankan      html  css  js  c++  java
  • silverlight DragAndDropSample 示例

    参考自: http://www.cnblogs.com/chenkai/archive/2010/05/26/1744226.html#1876533  and

    http://www.silverlight.net/content/samples/sl4/toolkitcontrolsamples/run/default.html

    xmal

    <UserControl x:Class="System.Windows.Controls.Samples.DragAndDropSample"
        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"
        xmlns:win
    ="clr-namespace:System.Windows;assembly=System.Windows.Controls"
        xmlns:controls
    ="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"
        xmlns:controlsToolkit
    ="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Toolkit"
        xmlns:chartingToolkit
    ="clr-namespace:System.Windows.Controls.DataVisualization.Charting;assembly=System.Windows.Controls.DataVisualization.Toolkit"
        xmlns:layoutToolkit
    ="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Layout.Toolkit"
        
    >
        
        
    <Grid x:Name="LayoutRoot" Background="White">
            
    <Grid.RowDefinitions>
                
    <RowDefinition Height="20"/>
                
    <RowDefinition Height="400"/>
            
    </Grid.RowDefinitions>
            
    <Grid.ColumnDefinitions>
                
    <ColumnDefinition Width="400"/>
                
    <ColumnDefinition Width="400"/>
            
    </Grid.ColumnDefinitions>

            
    <TextBlock Text="All Employees" Margin="0,0,262,0" Width="138" />
            
    <controlsToolkit:ListBoxDragDropTarget Grid.Column="0" Grid.Row="1" AllowDrop="True" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" x:Name="first">
                
    <ListBox x:Name="fromListBox" SelectionMode="Extended"  DisplayMemberPath="Name" Height="396" Width="396">
                    
    <ListBox.ItemsPanel>
                        
    <ItemsPanelTemplate>
                            
    <StackPanel Orientation="Vertical"/>
                        
    </ItemsPanelTemplate>
                    
    </ListBox.ItemsPanel>          
                
    </ListBox>
            
    </controlsToolkit:ListBoxDragDropTarget>

            
    <TextBlock Text="Organization Hierarchy" Grid.Column="1" Grid.Row="0"/>

            
    <controlsToolkit:ListBoxDragDropTarget Grid.Column="1" Grid.Row="1" AllowDrop="true" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" x:Name="two">
                
    <ListBox x:Name="fromListBox1" SelectionMode="Extended"  DisplayMemberPath="Name" Height="396" Width="396">
                    
    <ListBox.ItemsPanel>
                        
    <ItemsPanelTemplate>
                            
    <StackPanel Orientation="Vertical"/>
                        
    </ItemsPanelTemplate>
                    
    </ListBox.ItemsPanel>
                
    </ListBox>
            
    </controlsToolkit:ListBoxDragDropTarget>
            
    <Button Content="Button" Grid.RowSpan="2" Height="23" HorizontalAlignment="Left" Margin="208,0,0,0" Name="button1" VerticalAlignment="Top" Width="75" Click="button1_Click" />
        
    </Grid>
    </UserControl>

    c#

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Net;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Documents;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Animation;
    using System.Windows.Shapes;
    using System.Collections.ObjectModel;

    namespace System.Windows.Controls.Samples
    {
        
    public partial class DragAndDropSample : UserControl
        {
            
    public DragAndDropSample()
            {
                InitializeComponent();
                fromListBox.ItemsSource 
    = PersonDataProvider.GetData();
            }

            
    private void button1_Click(object sender, RoutedEventArgs e)
            {
                ItemCollection tc 
    = fromListBox1.Items;
            }
        }

        
    public class Person
        {
            
    private string name;

            
    public string Name
            {
                
    get { return name; }
                
    set { name = value; }
            }
        }

        
    public class PersonDataProvider
        {
            
    public static ObservableCollection<Person> GetData()
            {
                
    return new ObservableCollection<Person>
                            {
                                
    new Person { Name = "Akash Sharma" },
                                
    new Person { Name = "Vinay Sen" },
                                
    new Person { Name = "Lalit Narayan" },
                                
    new Person { Name = "Madhumita Chatterjee" },
                                
    new Person { Name = "Priyanka Patil" },
                                
    new Person { Name = "Kumar Sanu" }
                            };
            }
        }
    }
  • 相关阅读:
    黎活明给程序员的忠告
    servlet单实例多线程模式
    Servlet 获取多个参数
    Java Servlet学习笔记(四)Servlet客户端Http请求
    JavaWeb 后端 <二> 之 Servlet 学习笔记
    Servlet 规范笔记—基于http协议的servlet
    Servlet 规范笔记—servlet概念及结构
    看懂UML类图和时序图
    hibernate中的事务管理是怎么概念?
    Jquery中$.get(),$.post(),$.ajax(),$.getJSON()的用法总结
  • 原文地址:https://www.cnblogs.com/xh831213/p/1782293.html
Copyright © 2011-2022 走看看