yqchamberlain
yqchamberlain
采纳率50%
2014-12-02 15:15 阅读 3.6k

在wpf里面怎么动态的移动lable控件

在wpf里面怎么动态的移动lable控件,求大神指教,最好有代码。

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

1条回答 默认 最新

  • caozhy 从今以后生命中的每一秒都属于我爱的人 2014-12-02 18:59

    public static class DispatcherHelper

    {

    [SecurityPermissionAttribute(SecurityAction.Demand, Flags = SecurityPermissionFlag.UnmanagedCode)]

    public static void DoEvents()

    {

    DispatcherFrame frame = new DispatcherFrame();

    Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Background, new DispatcherOperationCallback(ExitFrames), frame);

    try { Dispatcher.PushFrame(frame); }

    catch (InvalidOperationException) { }

    }

    private static object ExitFrames(object frame)

    {

    ((DispatcherFrame)frame).Continue = false;

    return null;

    }

    }

    调用
    for (int i = 1; i < 10; i++)
    {
    System.Threading.Thread.Sleep(100);
    DispatcherHelper.DoEvents();
    label1.Left += 10;
    }

    点赞 评论 复制链接分享

相关推荐