Silverlight ToolKit DragDrop问题

时间:2010-07-22 13:20:03

标签: xaml silverlight-4.0 drag-and-drop silverlight-toolkit

我有两个网格的窗格,两个网格中都有一个列表框。我想添加Drag& amp;将功能拖放到窗格,以便用户可以拖动左侧列表框中的列表元素并将其放在右侧列表框中。我发现了许多很棒的教程,我可以在窗格中添加相应的代码,但是当应用程序运行时,我点击了我的窗格的菜单项,它没有加载。如果我删除拖动& drop代码一切正常,所以问题绝对是Drag&删除功能。

<telerikDocking:RadPane x:Class="Module_TestModule1.PaneSzD" telerikDocking:RadDocking.SerializationTag="Module_TestModule1.PaneSzD"
    xmlns:telerikDocking="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Docking"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"                             
    xmlns:toolkit="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Toolkit"                        
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Name="PaneSzD1" Header="PaneSzD" IsHidden="True">
<StackPanel Orientation="Horizontal">
    <Grid x:Name="LeftGrid" Width="250">
        <Grid.ColumnDefinitions>
            <ColumnDefinition/>
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition/>
            <RowDefinition/>
        </Grid.RowDefinitions>
        <toolkit:ListBoxDragDropTarget AllowDrop="True" Grid.Row="0">
            <ListBox Name="lbLRecords">
            <ItemsPanelTemplate>
                <StackPanel Orientation="Vertical" />
            </ItemsPanelTemplate>
        </ListBox>
        </toolkit:ListBoxDragDropTarget>
        <StackPanel Grid.Row="1" Height="Auto">
            <TextBox Name="tbLRecord" KeyDown="tbLRecord_KeyDown" />
            <Button Name="btnLAddRecord" Content="Add Record" Height="30" Click="btnLAddRecord_Click" ></Button>
        </StackPanel>
    </Grid>
    <StackPanel Orientation="Vertical">
        <Button Name="btnLMoveRecord" Content="Move Record From Left" Height="30" Click="btnLMoveRecord_Click" Margin="10,5,10,5" />
        <Button Name="btnRMoveRecord" Content="Move Record From Right" Height="30" Click="btnRMoveRecord_Click" Margin="10,5,10,5" />
    </StackPanel>
    <Grid x:Name="RightGrid" Width="250">
        <Grid.ColumnDefinitions>
            <ColumnDefinition/>
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition/>
            <RowDefinition/>
        </Grid.RowDefinitions>
        <toolkit:ListBoxDragDropTarget AllowDrop="True" Grid.Row="0">
            <ListBox Name="lbRRecords">
                <ItemsPanelTemplate>
                    <StackPanel Orientation="Vertical" />
                </ItemsPanelTemplate>
            </ListBox>
        </toolkit:ListBoxDragDropTarget>
        <StackPanel Grid.Row="1" Height="Auto">
            <TextBox Name="tbRRecord" KeyDown="tbRRecord_KeyDown" />
            <Button Name="btnRAddRecord" Content="Add Record" Height="30" Click="btnRAddRecord_Click"></Button>
        </StackPanel>
    </Grid>
    </StackPanel>
</telerikDocking:RadPane>

感谢您的帮助!

1 个答案:

答案 0 :(得分:0)

使用Silverlight Control Toolkit执行此操作的所有信息均可在此处找到:http://themechanicalbride.blogspot.com/2009/08/new-with-silverlight-toolkit-drag-and.html