We have seen a code-behind approach for the BusyIndicator
where based on the Load
operation, we set the IsBusy
property of the BusyIndicator
to true
or false
. The following example shows a sample code which enables the BusyIndicator
during continuous operations and using the code-behind approach.
biLoading.IsBusy = true;
biLoading.IsBusy = false;
The above approach is straightforward and this post is about how to use the BusyIndicator
declaratively along with XAML code. As we know, the DomainDataSource
control enables interaction between the XAML user interface and the DataContext
. Mostly, it is used for achieving binding to a specific control through XAML.
The sample code used for data binding using the DomainDataSource
control is as follows:
<riaControls:DomainDataSource AutoLoad="True"
d:DesignData="{d:DesignInstance my:CustomerPresentationModel,
CreateList=true}" Height="0"
LoadedData="customerPresentationModelDomainDataSource_LoadedData"
Name="customerPresentationModelDomainDataSource"
QueryName="GetCustomersWithAddressQuery" Width="0"
LoadSize="30" PageSize="10">
<riaControls:DomainDataSource.DomainContext>
<my:ADVWORKDomainContext />
</riaControls:DomainDataSource.DomainContext>
</riaControls:DomainDataSource>
More details about the DomainDataSource
control can be found here.
Using the BusyIndicator Declaratively, Along with XAML
Let's say we want to implement the above BusyIndicator
scenario not using the code behind. To do that, drag and drop the BusyIndicator
control to the Silverlight page and make the following changes to the XAML code:
<toolkit:BusyIndicator Height="75" HorizontalAlignment="Center"
Margin="0" Name="biLoading"
VerticalAlignment="Center" Width="200"
IsBusy="{Binding Path=IsBusy,
ElementName=customerPresentationModelDomainDataSource}"
IsEnabled="True" />
Bind the Isbusy
property of the BusyIndicator
to the DomainDataSource
control, exactly the same as above.