是否有可能以显示其中WinForms应用程序SilverLight的忙闲指示? [英] Is it possible to show SilverLight busy indicator inside Winforms application?

查看:215
本文介绍了是否有可能以显示其中WinForms应用程序SilverLight的忙闲指示?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前我使用的是简单的图片框 GIF文件内,不知道这是可能的,如果是的话这是什么2选项之间的差异

这是我在这个时刻用图片框

  pictureBox1.BringToFront();
pictureBox1.Dock = DockStyle.None;
pictureBox1.Visible =真;
 

解决方案

您可以尝试主机内的WinForms的SilverLight

虽然Silverlight是打算在Web浏览器中使用,WPF更加的本机的桌面和WPF确实有simimar的 BusyIndi​​cator控件,它是从的 codePLEX扩展WPF工具包

首先定义一个WPF用户控件 MyBusyIndi​​cator

 <用户控件X:类=Stackoverflow.MyBusyIndi​​cator
         的xmlns =htt​​p://schemas.microsoft.com/winfx/2006/xaml/$p$psentation
         的xmlns:X =htt​​p://schemas.microsoft.com/winfx/2006/xaml
         的xmlns:MC =htt​​p://schemas.openxmlformats.org/markup-compatibility/2006
         的xmlns:D =htt​​p://schemas.microsoft.com/ex$p$pssion/blend/2008
         的xmlns:xctk =CLR的命名空间:Xceed.Wpf.Toolkit;装配= Xceed.Wpf.Toolkit
         MC:可忽略=D
         D:DesignHeight =300D:DesignWidth =300>
    <电网>
        < xctk:BusyIndi​​cator控件IsBusy =真/>
    < /网格>
< /用户控件>
 

然后就可以使用的ElementHost ,首先添加的ElementHost 从窗体的设计器宿主在winform该用户控件,并在表的构造

 公共部分类MyForm的:表
{
    公共MyForm的()
    {
        的InitializeComponent();
        this.elementHost1.Child =新Stackoverflow.MyBusyIndi​​cator();
    }
}
 

的区别:

BusyIndi​​cator控件带有一些属性,让你自定义的指标,它增加了对SL或WPF的依赖。随着图片框所有你需要做的是preparing GIF动画。有许多工具生成GIF动画。

Currently i am using a simple PictureBox with GIF file inside and wonder if this is possible and if it does what the differences between this 2 options

This is what i have at this moment using PictureBox:

pictureBox1.BringToFront();
pictureBox1.Dock = DockStyle.None;
pictureBox1.Visible = true;

解决方案

You can try hosting SilverLight inside Winforms.

While SilverLight is intended to be used in a web browser, WPF is more native to desktop, and WPF does have a simimar BusyIndicator, it is downloadable from CodePlex-Extended WPF Toolkit.

First define a WPF user control MyBusyIndicator.

<UserControl x:Class="Stackoverflow.MyBusyIndicator"
         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
         xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
         xmlns:xctk="clr-namespace:Xceed.Wpf.Toolkit;assembly=Xceed.Wpf.Toolkit"
         mc:Ignorable="d" 
         d:DesignHeight="300" d:DesignWidth="300">
    <Grid>
        <xctk:BusyIndicator IsBusy="True" />
    </Grid>
</UserControl>

Then you can host this user control in Winform using an ElementHost, first you add the ElementHost from Form's designer, and in Form's constructor

public partial class MyForm : Form
{
    public MyForm ()
    {
        InitializeComponent();
        this.elementHost1.Child = new Stackoverflow.MyBusyIndicator();
    }
}

The differences:

While BusyIndicator comes with some properties to let you customize the indicator, it adds a dependency on SL or WPF. With PictureBox all you need to do is preparing animated GIFs. There are many tools for generating animated GIFs.

这篇关于是否有可能以显示其中WinForms应用程序SilverLight的忙闲指示?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆