我的应用中有一个页面,其中的数据来自Web服务。代码是:
public about()
{
InitializeComponent();
KejriwalService.aapSoapClient myclient = new KejriwalService.aapSoapClient();
myclient.getarvindAboutCompleted += new EventHandler<KejriwalService.getarvindAboutCompletedEventArgs>(myclient_getarvindAboutCompleted);
myclient.getarvindAboutAsync();
}
void myclient_getarvindAboutCompleted(object sender, KejriwalService.getarvindAboutCompletedEventArgs e)
{
var data = e.Result;
XElement xml = XElement.Parse(data);
aboutview.Text = xml.Elements("UserDetails").Elements("about_details").First().Value;
}
由于数据来自网络,我想添加一个运行直到数据到来的微调器。任何人都可以帮助我如何为这个特定的页面做这个。
我的xaml文件是:
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,12,12,0">
<Button Click="Image_Phone" BorderThickness="0" Margin="197,155,0,518" HorizontalAlignment="Left" Width="93">
<Button.Background>
<ImageBrush Stretch="Fill" ImageSource="Image/phone.png"/>
</Button.Background>
</Button>
<Button x:Name="Email" BorderThickness="0" Click="Image_Email" Margin="277,155,85,518">
<Button.Background>
<ImageBrush Stretch="Fill" ImageSource="Image/email.png"/>
</Button.Background>
</Button>
<Button x:Name="Home" BorderThickness="0" Click="Image_Home" Margin="0,155,-12,518" HorizontalAlignment="Right" Width="102">
<Button.Background>
<ImageBrush Stretch="Fill" ImageSource="Image/Home-icon.png"/>
</Button.Background>
</Button>
<Button x:Name="previous" BorderThickness="0" Click="Image_Back" Margin="0,0,354,673" HorizontalAlignment="Right" Width="102">
<Button.Background>
<ImageBrush Stretch="Fill" ImageSource="Image/Previous.png"/>
</Button.Background>
</Button>
<ScrollViewer Margin="0,256,0,6" HorizontalScrollBarVisibility="Visible" VerticalScrollBarVisibility="Auto" AllowDrop="False" ManipulationMode="Control">
<TextBlock HorizontalAlignment="Left" Name="aboutview" Text="" TextWrapping="Wrap" VerticalAlignment="Top" Width="439" FontSize="18" FontStyle="Normal" FontWeight="ExtraBlack" Foreground="Black"/>
</ScrollViewer>
<Image Height="172" HorizontalAlignment="Left" Margin="24,78,0,0" Name="image1" Source="Image/icon.png" Stretch="Fill" VerticalAlignment="Top" Width="155" />
<TextBlock Height="34" HorizontalAlignment="Left" Margin="196,78,0,0" Name="textBlock1" Text="Contact No:" VerticalAlignment="Top" Width="147" FontSize="24" Foreground="Black" FontWeight="Bold"/>
<TextBlock Height="36" HorizontalAlignment="Left" Margin="197,118,0,0" Name="textBlock2" Text="+91-9718500606" VerticalAlignment="Top" Width="191" FontSize="24" Foreground="Black" FontWeight="Bold" />
</Grid>
</Grid>
答案 0 :(得分:1)
如果符合您的要求,我建议您使用ProgressBar(或WP工具包中更好的PerformanceProgressBar)。您可以在ContentPanel网格内的某处添加此代码段:
<ProgressBar Name="progressName"
IsIndeterminate="True"
Visibility="Collapsed"/>
你的代码背后应该是这样的:
public about()
{
InitializeComponent();
KejriwalService.aapSoapClient myclient = new KejriwalService.aapSoapClient();
myclient.getarvindAboutCompleted += new EventHandler<KejriwalService.getarvindAboutCompletedEventArgs>(myclient_getarvindAboutCompleted);
myclient.getarvindAboutAsync();
progressName.Visibility = System.Windows.Visibility.Visible;
}
void myclient_getarvindAboutCompleted(object sender, KejriwalService.getarvindAboutCompletedEventArgs e)
{
var data = e.Result;
XElement xml = XElement.Parse(data);
aboutview.Text = xml.Elements("UserDetails").Elements("about_details").First().Value;
progressName.Visibility = System.Windows.Visibility.Collapsed;
}