This article describe Build a Simple Application with .Net RIA Services in Silverlight 3. If you’re looking for more information about Silverlight, you can visit ASPHostDirectory. We always ready to host your site. You can start from only $ 3.99/month to get this hosting. So, what are you waiting for?
Use a DomainDataSource to easily connect the data
Remove the code that retrieves the data from the server. Open Views\HomePage.xaml and comment out all the code in the Page_Loaded method.
Instead of loading the data manually, add a DomainDataSource control to the page. To do this, add a reference to System.Windows.Ria.Controls.dll, and add the Xml namespace that relates to its contents:
<navigation:Page x:Class="BankApp.HomePage"
...
xmlns:ria="clr-namespace:System.Windows.Controls;
assembly=System.Windows.Ria.Controls"
Loaded="Page_Loaded"
Title="HomePage Page"> ...
</navigation:Page>
Add the DomainDataSource to the page
<navigation:Page x:Class="BankApp.HomePage"
...
<Grid x:Name="LayoutRoot" Background="White">
<ria:DomainDataSource x:Name="customersDataSource"
LoadMethodName="GetCustomers"
AutoLoad="True"
LoadSize="5">
</ria:DomainDataSource>
...
</Grid>
</navigation:Page>
Reminder: After creating the DomainService in the server side, Visual Studio has generated a client side DomainContext that does all the magic of connecting to the server for us.
Assign the DomainContext to the DomainDataSource so it can use it to pull data from the server. To do that, add a local xml namespace:
<navigation:Page x:Class="BankApp.HomePage"
...
xmlns:local="clr-namespace:BankApp.Web"
Title="HomePage Page">
...
</navigation:Page>
And do the assignment:
<ria:DomainDataSource x:Name="customersDataSource"
LoadMethodName="LoadCustomers"
AutoLoad="True"
LoadSize="5">
<ria:DomainDataSource.DomainContext>
<local:BankDomainContext />
</ria:DomainDataSource.DomainContext>
</ria:DomainDataSource>
The last thing we need to do is to bind the DataGrid to the DomainDataSource.
<data:DataGrid MinHeight="200"
x:Name="dataGrid"
ItemsSource="{Binding Data, ElementName=customersDataSource}">
</data:DataGrid>
Run the application, and see how the data is being loaded in chunks according to the LoadSize property of the DomainDataSource.
Add a DataPager Control to enable paging through the data. To do that, add a reference to System.Windows.Controls.Data.DataForm.dll the following xml namespace:
xmlns:dataControls=
"clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data.DataForm”
Add the DataPager control and bind it to the DomainDataSource:
<data:DataGrid MinHeight="200" ...>
</data:DataGrid>
<dataControls:DataPager PageSize="3"
Source="{Binding Data, ElementName=customersDataSource}" />
Data Grouping
Add Grouping support to the DataGrid. Add the following xml namespace:
xmlns:riaData="clr-namespace:System.Windows.Data;assembly=System.Windows.Ria.Controls"
Then, add a group descriptor to group the results by the property City.
<ria:DomainDataSource ...>
<ria:DomainDataSource.GroupDescriptors>
<riaData:GroupDescriptor PropertyPath="City" />
</ria:DomainDataSource.GroupDescriptors>
</ria:DomainDataSource>
Data Sorting
To add sorting support, add a SortDescriptor:
<ria:DomainDataSource ...>
<ria:DomainDataSource.SortDescriptors>
<riaData:SortDescriptor PropertyPath="CustomerID"
Direction="Descending" />
</ria:DomainDataSource.SortDescriptors>
</ria:DomainDataSource>
Rich Data Filtering
Add a dynamic filtering support based on a selected value of a CheckBox. Add a Checkbox above the DataGrid.
<CheckBox x:Name="chkBusiness"
Content="Business Customer ?" />
<data:DataGrid x:Name="dataGrid" ...> </data:DataGrid>
Add a FilterDescriptor that filters data according to the IsBusiness property of each item. Bind the FilterDescriptor to the IsChecked property of the above checkbox.
<ria:DomainDataSource x:Name="customersDataSource" ... >
...
<ria:DomainDataSource.FilterDescriptors>
<riaData:FilterDescriptorCollection>
<riaData:FilterDescriptor PropertyPath="IsBusiness"
Operator="IsEqualTo">
<riaData:ControlParameter ControlName="chkBusiness"
PropertyName="IsChecked"
RefreshEventName="Click" />
</riaData:FilterDescriptor>
</riaData:FilterDescriptorCollection>
</ria:DomainDataSource.FilterDescriptors>
</ria:DomainDataSource>
What is so SPECIAL on ASPHostDirectory.com Silverlight Hosting?
We know that finding a cheap, reliable web host is not a simple task so we’ve put all the information you need in one place to help you make your decision. At ASPHostDirectory, we pride ourselves in our commitment to our customers and want to make sure they have all the details they need before making that big decision.
We will work tirelessly to provide a refreshing and friendly level of customer service. We believe in creativity, innovation, and a competitive spirit in all that we do. We are sound, honest company who feels that business is more than just the bottom line. We consider every business opportunity a chance to engage and interact with our customers and our community. Neither our clients nor our employees are a commodity. They are part of our family.
The followings are the top 10 reasons you should trust your online business and hosting needs to us:
- FREE domain for Life - ASPHostDirectory gives you your own free domain name for life with our Professional Hosting Plan and 3 free domains with any of Reseller Hosting Plan! There’s no need to panic about renewing your domain as ASPHostDirectory will automatically do this for you to ensure you never lose the all important identity of your site
- 99,9% Uptime Guarantee - ASPHostDirectory promises it’s customers 99.9% network uptime! We are so concerned about uptime that we set up our own company to monitor people’s uptime for them called ASPHostDirectory Uptime
- 24/7-based Support - We never fall asleep and we run a service that is opening 24/7 a year. Even everyone is on holiday during Easter or Christmast/New Year, we are always behind our desk serving our customers
- Customer Tailored Support - if you compare our hosting plans to others you will see that we are offering a much better deal in every aspect; performance, disk quotas, bandwidth allocation, databases, security, control panel features, e-mail services, real-time stats, and service
- Money Back Guarantee - ASPHostDirectory offers a ‘no questions asked’ money back guarantee with all our plans for any cancellations made within the first 30 days of ordering. Our cancellation policy is very simple - if you cancel your account within 30 days of first signing up we will provide you with a full refund
- Experts in Silverlight Hosting - Given the scale of our environment, we have recruited and developed some of the best talent in the hosting technology that you are using. Our team is strong because of the experience and talents of the individuals who make up ASPHostDirectory
- Daily Backup Service - We realise that your website is very important to your business and hence, we never ever forget to create a daily backup. Your database and website are backup every night into a permanent remote tape drive to ensure that they are always safe and secure. The backup is always ready and available anytime you need it
- Easy Site Administration - With our powerful control panel, you can always administer most of your site features easily without even needing to contact for our Support Team. Additionally, you can also install more than 100 FREE applications directly via our Control Panel in 1 minute!
Happy Hosting!