SilverLight-非托管代码初始化进度条显示方法

<object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="100%" height="100%">
        <param  name="SplashScreenSource" value="SplashScreen.xaml"/>
        <param name="OnSourceDownloadProgressChanged" value="OnSourceDownloadProgressChanged" />

<param name="source" value="ClientBin/SilverLightAppTest.xap"/>
      <param name="onError" value="onSilverlightError" />
      <param name="background" value="white" />
     <param name="minRuntimeVersion" value="4.0.50826.0" />
     <param name="autoUpgrade" value="true" />
    <a href="http://go.microsoft.com/fwlink/?LinkID=149156&v=4.0.50826.0" style="text-decoration:none">
   <img src="http://go.microsoft.com/fwlink/?LinkId=161376" alt="获取 Microsoft Silverlight" style="border-style:none"/>
    </a>

</object>

在SilverLight加载时Object标签中新加入两个参数:

1.SplashScreenSource属性用于标记初始屏幕xaml页

2.OnSourceDownloadProgressChanged属性用于加载进度变化时的事件处理程序

程序如下:

SplashScreenSource.xaml:

<Grid x:Name="LayoutRoot" Background="White">
        <StackPanel HorizontalAlignment="Center">
            <Grid HorizontalAlignment="Center">
                <Rectangle Stroke="#FFDEE6F0" HorizontalAlignment="Left" Width="300" 
Height="10" RadiusX="2" RadiusY="2" StrokeThickness="1"/>
                <Rectangle Fill="#FF7E99C8" HorizontalAlignment="Left" VerticalAlignment="Center" 
StrokeThickness="0" RadiusX="0" RadiusY="0" Width="296" Height="6" x:Name="progressBar" 
RenderTransformOrigin="0,0.5" Margin="4">
                    <Rectangle.RenderTransform>
                        <ScaleTransform x:Name="progressBarScale" />
                    </Rectangle.RenderTransform>
                </Rectangle>
            </Grid>
            <Grid HorizontalAlignment="Center">
                <TextBlock x:Name="progressText" Margin="18,0,17,19" Height="26" Text="0%" 
FontSize="16" Opacity="0.8" VerticalAlignment="Bottom" TextAlignment="Right"/>
                <TextBlock x:Name="progressText2" Margin="18,0,7,8" Height="70" Text="0%" 
FontSize="50" Opacity="0.04" FontWeight="Bold" VerticalAlignment="Bottom" TextAlignment="Right"/>
            </Grid>
        </StackPanel>
    </Grid>

OnSourceDownloadProgressChanged

function OnSourceDownloadProgressChanged(sender, args) {
            sender.findName("progressText").Text = Math.round(eventArgs.progress * 100) + "%";
            sender.findName("progressText2").Text = Math.round(eventArgs.progress * 100) + "%";
            sender.findName("progressBarScale").ScaleX = eventArgs.progress;
        }

这样就自定义了一个非托管代码的初始化进度条显示.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值