Wednesday, October 26, 2011

Busy Indicator (known as activity control in SL3)

Today in this post I will talk about Busyindicator which is very small but very important control for silverlight applications. While data or streaming is loading its obviously that it requires some time to load. In mean its necessary to give user a symbol of progress otherwise user don't know what going on in background.

Lets suppose you have Datagrid control which is bound to DomainSourceControl and it is loading some data from database via RIA Services. You just need to bind the IsBusy property of Busyindicator to datasource IsBusy property. Dadadada you are done.

Note if you exapand the BusyIndicator tag and include DataGrid or any DataForm it will show only in area that is covered by those control otherwise you can add it by single tag on top of the page it will show in middle of page and it will cover the whole page area.

<toolkit:BusyIndicator x:Name="activity" IsBusy="{Binding Path=IsBusy, ElementName=DataSource}"  BusyContent="Loading...">

<data:DataGrid Name="DG" ItemsSource="{Binding Data, ElementName=DataSource}" MinHeight="100" Height="200"  AutoGenerateColumns="False" IsReadOnly="False"  >
                            <data:DataGridTextColumn Binding="{Binding Company_Id}" Header="ID"></data:DataGridTextColumn>
                            <data:DataGridTextColumn Binding="{Binding Company_Name}" Header="Name"></data:DataGridTextColumn>
                            <data:DataGridTemplateColumn Header="Type">                               
<ComboBox Margin="2" SelectedValue="{Binding Company_Type_Id, Mode=TwoWay}" SelectedValuePath="Company_Type_Id" ItemsSource="{Binding [Company_Type], Source={StaticResource MyLookup}}" DisplayMemberPath="Description"/>                                                                                   


<riaControl:DomainDataSource x:Name="DataSource" QueryName="GetCompanies" AutoLoad="True" LoadSize="10" DomainContext="{StaticResource TestDomainContext}" />
You can configure the Content property of BusyIndicator and can write proper message for user that whats going on actually why user need to wait.

If you liked please don't forget to write comments it will increase my blood.


No comments:

Post a Comment