您好我是来自NuGet的恭喜FrameWork。但它有一些问题,当我从右到左吸毒时,它没关系。但是从左到右的药物不起作用。
<Window x:Class="DragAndDropBehavior.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:dd="clr-namespace:GongSolutions.Wpf.DragDrop;assembly=GongSolutions.Wpf.DragDrop"
Title="MainWindow" Height="350" Width="525" Closing="Window_Closing">
<StackPanel>
<ItemsControl dd:DragDrop.IsDragSource="True" dd:DragDrop.IsDropTarget="True" ItemsSource="{Binding Items}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<UniformGrid Rows="2" Columns="4" />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Border BorderBrush="#FF000000" BorderThickness="1,1,1,1" CornerRadius="8,8,8,8" Margin="5">
<Grid>
<Grid.RowDefinitions>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<Label Grid.Row="0" Content="{Binding .}" Grid.ColumnSpan="2"></Label>
</Grid>
</Border>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</StackPanel>
不要查看序列化
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using GongSolutions.Wpf;
using System.Xml.Serialization;
using System.IO;
namespace DragAndDropBehavior
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
///
[Serializable]
public class TestSer
{
public ObservableCollection<string> Items { get; set; }
public TestSer()
{
Items = new ObservableCollection<string>() { "1", "2", "3", "4" ,"5","6","7","8"};
}
}
public partial class MainWindow : Window
{
static public void SerializeToXML(TestSer movie)
{
XmlSerializer serializer = new XmlSerializer(typeof(TestSer));
TextWriter textWriter = new StreamWriter(@"C:\Users\Public\Boxes.xml");
serializer.Serialize(textWriter, movie);
textWriter.Close();
}
static TestSer DeserializeFromXML()
{
XmlSerializer deserializer = new XmlSerializer(typeof(TestSer));
TextReader textReader = new StreamReader(@"C:\Users\Public\Boxes.xml");
TestSer movies;
movies = (TestSer)deserializer.Deserialize(textReader);
textReader.Close();
return movies;
}
TestSer Some;
public MainWindow()
{
//Some = new TestSer();
//Some.Items.Clear();
//Some = DeserializeFromXML();
this.DataContext = new TestSer();
InitializeComponent();
}
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
SerializeToXML(Some);
}
}
}
* *