Sử Dụng Busy Indicator Control Trong Silverlight

I.Introdution

Trong bài này mình xin chia sẻ cách sử dụng Busy Indicator Control trong Silverlight

II.Coding

  • Mở Visual Studio lên và tao Silverlight Application
  • Thiết kế giao diện cho ứng dụng gồm:

Button ( tạo sự kiện lick)

BusyIndicator

image

Code XAML giao diện:

   1: <UserControl

   2:     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

   3:     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

   4:     xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk" xmlns:toolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit"

   5:     x:Class="Busy.MainPage"

   6:     Width="640" Height="480">

   7:  

   8:     <Grid x:Name="LayoutRoot" Margin="1" HorizontalAlignment="Center" VerticalAlignment="Center" Height="480">

   9:         <Grid.Background>

  10:             <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">

  11:                 <GradientStop Color="Black" Offset="0"/>

  12:                 <GradientStop Color="White" Offset="1"/>

  13:             </LinearGradientBrush>

  14:         </Grid.Background>

  15:         <Button Content="Click" VerticalAlignment="Top" HorizontalAlignment="Right" Width="638" Click="btn_click" Height="43" Margin="0,47,1,0" />

  16:         <toolkit:BusyIndicator x:Name="BusyWindow" Content="" Visibility="Collapsed" Margin="-2,91,1,0" Height="388" VerticalAlignment="Top" Width="639" />

  17:     </Grid>

  18: </UserControl>

Tiếp theo chúng ta xử lý trong sự kiện Click :

   1: private void btn_click(object sender, System.Windows.RoutedEventArgs e)

   2: {

   3:     // TODO: Add event handler implementation here.

   4:     BusyWindow.Visibility = Visibility.Visible;

   5:     BusyWindow.BusyContent = "Please Wait When I Coding ......";

   6:     BusyWindow.IsBusy = true;

   7: }

Bây giờ Chạy ứng dụng để xem kết quả

image

/*Web is beautiful*/

Leave a comment