うまくいけば、これは簡単な質問です。Silverlight Toolkit のを使用して、ある場所から別の場所へのListBoxDragDropTarget
ドラッグ アンド ドロップを設定していますListBox
。イベントを発生させることができないようです。これが私のXAMLコードです:
<toolkit:ListBoxDragDropTarget HorizontalAlignment="Left"
HorizontalContentAlignment="Stretch"
VerticalAlignment="Top"
VerticalContentAlignment="Stretch"
Margin="39,117,0,0"
Grid.Row="1"
AllowDrop='True'>
<ListBox x:Name='columnHeadings'
MinHeight='100'
MinWidth='100'>
</ListBox>
</toolkit:ListBoxDragDropTarget>
<toolkit:ListBoxDragDropTarget AllowDrop='True'
Grid.Column='1'
Grid.Row='1'
HorizontalContentAlignment="Stretch"
VerticalContentAlignment="Stretch"
VerticalAlignment="Center"
HorizontalAlignment="Left">
<ListBox x:Name='customerFields'
Grid.Column='1'
Grid.Row='1'
Visibility='Collapsed'
Drop='CustomerFieldsDrop'>
</ListBox>
</toolkit:ListBoxDragDropTarget>
コード ビハインド ページのイベント ハンドラーは次のとおりです。
private void CustomerFieldsDrop(object sender, DragEventArgs e)
{
MessageBox.Show(string.Format("Something was dropped!"));
}
ご覧のとおり、私は本当にシンプルなものを目指していました。List Boxの親ListBoxDragDropTarget
にイベント ハンドラーを割り当ててみました。customerFields
皮肉なことに、それはうまくいきました。
ここでの目的は、ユーザーがテキスト ファイルをインポートして、ファイルの列ヘッダーのリストを 1 つのリスト ボックスに取得し、それらを 2 番目のリスト ボックスにリストされているデータ フィールドに「接続」できるようにすることです。そのため、リストの並べ替えや、あるリストから別のリストへのアイテムの移動はありません。
columnHeadings.ItemsSource
プロパティはオブジェクトstring[]
です。customerFields.ItemsSource
プロパティはオブジェクトIEnumerable<string>
です。
任意の洞察をいただければ幸いです。