关键点:
1.利用WebClient的DownloadProgressChanged事件更新下载进度
2.下载完成后,分析Xap包的程序集Assembly信息

3.利用Assembly反射还原对象并加载到当前页中。

 

好处:
1.可以先定义一个简单的加载动画,吸引用户注意,避免长时间的无聊等待,改善用户体验。
2.实现按需加载,避免一次性下载过多内容。

3.在一定程度上,增加了破解难度,有助于代码保密。

Xaml :

<UserControl x:Class="LoadXap.MainPage"
    xmlns
="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x
="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d
="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    mc:Ignorable
="d" d:DesignWidth="640" d:DesignHeight="480">
  
<Grid x:Name="LayoutRoot">
      
<StackPanel VerticalAlignment="Center" HorizontalAlignment="Center" Orientation="Horizontal">
        
<ProgressBar Height="15" VerticalAlignment="Center" HorizontalAlignment="Center" Width="200" x:Name="pb1" Value="0"/>
        
<TextBlock x:Name="txtLoad" Text="0%" Margin="5,0,0,0"></TextBlock>
    
</StackPanel>       
  
</Grid>
</UserControl>

相关文章:

  • 2021-11-03
  • 2022-12-23
  • 2021-11-19
  • 2021-05-26
  • 2021-12-14
  • 2021-08-22
  • 2022-12-23
  • 2022-01-27
猜你喜欢
  • 2021-09-28
  • 2021-11-30
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案