У меня есть бизнес-приложение Silverlight 4, я установил Silverlight Toolkit в апреле 2011 года и добавил ссылку на проект.Я хочу изменить порядок списка с помощью перетаскивания.
Мой код следующий:
<Grid x:Name="LayoutRoot">
<toolkit:ListBoxDragDropTarget AllowDrop="True">
<ListBox AllowDrop="True" Name="listBox1">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Vertical"></StackPanel>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
</ListBox>
</toolkit:ListBoxDragDropTarget>
</Grid>
И
private void Page_Loaded(object sender, RoutedEventArgs e)
{
listBox1.ItemsSource = new Int32[] {1,2,3,4,5 };
}
При попытке перетащить элемент Iсм. «призрак» предмета и значок с двумя стрелками (стрелка вверх и вниз), но когда я его опускаю (в том же списке), ничего не происходит!Это не переупорядочено.
Что я делаю не так ???Должен ли я слушать событие и что-то реализовывать ??
Спасибо!
РЕДАКТИРОВАТЬ: Полный код:
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.Windows.Navigation;
namespace editorencuestas
{
public partial class testdragdrop : Page
{
public testdragdrop()
{
InitializeComponent();
}
protected override void OnNavigatedTo(NavigationEventArgs e)
{
}
private void Page_Loaded(object sender, RoutedEventArgs e)
{
listBox1.ItemsSource = new Int32[] {1,2,3,4,5 };
}
}
}
И
<navigation:Page x:Class="editorencuestas.testdragdrop"
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:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
d:DesignWidth="640" d:DesignHeight="480"
Title="testdragdrop Page" xmlns:toolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit" Loaded="Page_Loaded">
<Grid x:Name="LayoutRoot">
<toolkit:ListBoxDragDropTarget AllowDrop="True">
<ListBox x:Name="listBox1" Height="175" Width="147">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel />
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
</ListBox>
</toolkit:ListBoxDragDropTarget>
</Grid>
</navigation:Page>