silverlight   发布时间:2022-05-03  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了Silverlight DragDrop.DoDragDrop()大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

概述

我真的很难在Silverlight 4中使用简单的拖放示例. 这就是我所拥有的: XAML <UserControl x:Class="TestDragDrop.MainPage" Width="350" Height="200" xmlns="http://scheR_480_11845@as.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="h
我真的很难在Silverlight 4中使用简单的拖放示例.

这就是我所拥有的:

XAML

<UserControl x:Class="TestDragDrop.MainPage" Width="350" Height="200"
    xmlns="http://scheR_480_11845@as.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://scheR_480_11845@as.microsoft.com/winfx/2006/xaml">
    <Grid BACkground="White">
        <Rectangle Margin="50,50,200,50" Fill="Orange" MouSELEftButtonDown="r1_MouSELEftButtonDown" />
        <Rectangle Margin="200,50" Fill="Orange" AllowDrop="true" Drop="r2_Drop" />
    </Grid>
</UserControl>

代码隐藏

public partial class MainPage : UserControl
{
    public MainPage()
    {
        InitializeComponent();
    }

    private void r1_MouSELEftButtonDown(object sender,MouseButtonEventArgs E)
    {
        DragDrop.DoDragDrop((RectanglE)sender,"test data",DragDropEffects.All,DragDropKeyStates.LeftMouseButton);
    }

    private void r2_Drop(object sender,System.Windows.DragEventArgs E)
    {
        messageBox.Show("Drop: " + e.Data.ToString());
    }
}

DragDrop.DragDropCompleted事件会触发,但sender参数始终为null,事件参数并不能帮助我找到有关该事件的更多信息.

我也尝试使用实现IAcceptDrop的自定义控件而没有运气.

此外,当我开始拖动操作时,我没有视觉反馈表明发生了某些事情(光标或其他任何内容都没有变化).有什么不对?

我找到的所有样本都使用DragDropTargets.我唯一的办法是为我想要使用的特定类型的控件实现DragDropTarget吗?

解决方法

Silverlight 4的拖放功能针对单一场景:将文件从计算机拖到Silverlight应用程序上.您需要使用Toolkit的DragDropTarget控件. Tim Heuer的拖放功能说明:
http://timheuer.com/blog/archive/2009/11/18/whats-new-in-silverlight-4-complete-guide-new-features.aspx

换句话说,他们没有计划让您能够在代码中实际创建自己的拖动操作.

此URL中的大多数(如果不是全部)“限制”部分仍适用于SL4 RTW:
http://www.ningzhang.org/2009/11/28/silverlight-drag-and-drop-api/

大佬总结

以上是大佬教程为你收集整理的Silverlight DragDrop.DoDragDrop()全部内容,希望文章能够帮你解决Silverlight DragDrop.DoDragDrop()所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。