c# - 等待 0.1 秒直到隐藏图像

标签 c# visual-studio visual-studio-2010 windows-phone-7 wait

我正在用 C# 为 Windows Phone 制作一个小程序。它应该做的一件事是在用户点击“隐藏”按钮时隐藏按钮工具栏。

我已经完成了隐藏工具栏的代码。它像预期的那样隐藏了按钮。但是现在发生的情况是所有按钮立即消失。为了制作一种“动画”,我决定等待 0.1 秒直到隐藏所有按钮。

我将如何等待 .1 秒?

现在是我的代码。

    bool panelopened = false;

    private void image1_MouseEnter(object sender, MouseEventArgs e)
    {
        if (panelopened == false)
        {
            ImageSourceConverter imgs = new ImageSourceConverter();
            image1.SetValue(Image.SourceProperty, imgs.ConvertFromString("/Main%20View;component/Images/hide.png"));
            image3.Width = 50;
            image4.Width = 50;
            image5.Width = 50;
            panelopened = true;
        }
        else
        {
            ImageSourceConverter imgs = new ImageSourceConverter();
            image1.SetValue(Image.SourceProperty, imgs.ConvertFromString("/Main%20View;component/Images/more.png"));
            image3.Width = 0;
            image4.Width = 0;
            image5.Width = 0;
            panelopened = false;
        }
    } 

最佳答案

看看这个 previous answer .使用这个你可以做

Dispatcher.DelayInvoke(TimeSpan.FromSeconds(0.1), () => 
{
   image3.Width = 0;
   image4.Width = 0;
   image5.Width = 0;
}

关于c# - 等待 0.1 秒直到隐藏图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5606572/

相关文章:

c# - 为什么 C# ProcessStartInfoRedirectStandardOutput 会导致 xcopy 进程失败

c# - 使用 Entity Framework 存储类别的枚举或实际表?

在 Visual Studio 中将可变长度 c 字符串转换为 Fortran 字符串

c# - 如何开发DirectX应用程序?

visual-studio-2010 - Trace.WriteLine 不产生任何输出

c# ".datasource"未显示在框中

c# - 使用 c# 将 Sharepoint "list"从一个 Sharepoint 服务器 (2007) 复制到另一台服务器 (2010)

c# - 不再在 docker 中使用 dotnet watch 的理由是什么

silverlight - 如何阻止 VS 给我几种类型的 "System.OutofmemoryException"错误?

c# - 如何查看命名空间是从哪个 dll 导入的?