SIGN UP MEMBER LOGIN:    
ARTICLE

Silverlight 5 WCF RIA Services: Part 2

Posted by Mahadesh Mahalingappa Articles | .NET 4.5 August 22, 2011
In this article we are going to continue to explore the WCF Ria Services with Silverlight 5.
Reader Level:
Download Files:
 

As we saw in our prevoius example WCF Ria Services provide us with a clean and simple way of binding our control to our data model .

Now lets go one step further I would like to design a Complete User Page using WCF Ria Services .

Lets get started . Create a new page NewPage.xaml .

Go to the Data Source.

Silverlight 5 WCF RIA Services


Select the Associated Control as ComboBox .

Silverlight 5 WCF RIA Services

Click ok . and the icon changes to combo box as shown below :

Silverlight 5 WCF RIA Services

Simply Drag and Drop the Article Id on to the NewPage.xaml . The Design Page should now look as below :

Silverlight 5 WCF RIA Services

Modify the App.xaml to make the NewPage.xaml as the start up and give it a run .

Silverlight 5 WCF RIA Services

Now go back to the Data Source . select Title and customize .

Silverlight 5 WCF RIA Services

Select the Associated Control as TextBlock .

Silverlight 5 WCF RIA Services

Click Ok and the icon changes to TextBlock .

Silverlight 5 WCF RIA Services

Drag and Drop both to the designer area .

Silverlight 5 WCF RIA Services

Build and Run it . Title and Body corresponding to the article id are displayed .

Silverlight 5 WCF RIA Services

Modify the article Id .

Silverlight 5 WCF RIA Services

Title and Body are modified as shown below :

Silverlight 5 WCF RIA Services

Behind the scene this was the code that was generated . Wow now that would have been tough . Thanks to WCF Ria Services we were saved . All the Binding work was taken care for you by Ria services Support .

<UserControl x:Class="SLWCFRiaServices.NewPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    d:DesignHeight="300" d:DesignWidth="400" xmlns:riaControls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.DomainServices" xmlns:my="clr-namespace:SLWCFRiaServices.Web" xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk">

    <Grid x:Name="LayoutRoot" Background="White">
        <riaControls:DomainDataSource AutoLoad="True" d:DesignData="{d:DesignInstance my:Article, CreateList=true}" Height="0" LoadedData="articleDomainDataSource_LoadedData" Name="articleDomainDataSource" QueryName="GetArticlesQuery" Width="0">
            <riaControls:DomainDataSource.DomainContext>
                <my:DataDomainContext />
            </riaControls:DomainDataSource.DomainContext>
        </riaControls:DomainDataSource>
        <Grid DataContext="{Binding ElementName=articleDomainDataSource, Path=Data}" HorizontalAlignment="Left" Margin="56,29,0,0" Name="grid1" VerticalAlignment="Top">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>
            <sdk:Label Content="Article ID:" Grid.Column="0" Grid.Row="0" HorizontalAlignment="Left" Margin="3" VerticalAlignment="Center" />
            <ComboBox DisplayMemberPath="ArticleID" Grid.Column="1" Grid.Row="0" Height="23" HorizontalAlignment="Left" ItemsSource="{Binding Mode=OneWay}" Margin="3" Name="articleIDComboBox" VerticalAlignment="Center" Width="120">
                <ComboBox.ItemsPanel>
                    <ItemsPanelTemplate>
                        <VirtualizingStackPanel />
                    </ItemsPanelTemplate>
                </ComboBox.ItemsPanel>
            </ComboBox>
        </Grid>
        <Grid DataContext="{Binding ElementName=articleDomainDataSource, Path=Data}" HorizontalAlignment="Left" Margin="56,95,0,0" Name="grid2" VerticalAlignment="Top">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>
            <sdk:Label Content="Title:" Grid.Column="0" Grid.Row="0" HorizontalAlignment="Left" Margin="3" VerticalAlignment="Center" />
            <TextBlock Grid.Column="1" Grid.Row="0" Height="23" HorizontalAlignment="Left" Margin="3" Name="titleTextBlock" Text="{Binding Path=Title, Mode=TwoWay}" VerticalAlignment="Center" />
        </Grid>
        <Grid DataContext="{Binding ElementName=articleDomainDataSource, Path=Data}" HorizontalAlignment="Left" Margin="60,162,0,0" Name="grid3" VerticalAlignment="Top">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>
            <sdk:Label Content="Body:" Grid.Column="0" Grid.Row="0" HorizontalAlignment="Left" Margin="3" VerticalAlignment="Center" />
            <TextBlock Grid.Column="1" Grid.Row="0" Height="23" HorizontalAlignment="Left" Margin="3" Name="bodyTextBlock" Text="{Binding Path=Body, Mode=TwoWay}" VerticalAlignment="Center" />
        </Grid>
    </Grid>
</
UserControl>

In the next post we will learn about some advanced features of WCF RIA Services . Till Then . Happy Coding .
 

Login to add your contents and source code to this article
share this article :
post comment
 

Useful Article.........

Posted by Shalini Juneja Aug 22, 2011
Team Foundation Server Hosting
Become a Sponsor
PREMIUM SPONSORS
  • Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
    ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications. Visit DynamicPDF here
Nevron Gauge for SharePoint
Become a Sponsor