In this article we would be using all the concept we discussed in the 4 parts of
the series Silverlight 5 WCF RIA Service
http://www.c-sharpcorner.com/UploadFile/Mahadesh/8928/ and build a
complete Business Application .
If you go through the first 4 parts of the Series this Business App would be
very easy .
Lets get started .
Create a Data Model as shown below :
The Data Model look as the above diagram .
I would try to cover few Business requirements which would help us to create
more scenarios to test our knowledge on WCF Ria Services .
Lets create our Domain Service class . Build the Solution before that .
DataDomainService.cs and DataDomainService.metadata.cs classes are generated .
Build the Solution .
Create a Folder Views and add a new page Author.xaml .
Simply Drag and Drop the Author Entity onto the Views.Author Design Area .
Make sure AutoGenerateColumns="True" .
Now go to the Mainpage.xaml . Open the Designer View . you would see the below
in the toolbar .
Drag and Drop the Author User Control from the Toolbar to the MainPage.xaml.
In this wasy we can access the Author User Control from the MainPage itself . No
need for any other step .
The MainPage.xaml xaml code would look like as follows :
<UserControl
x:Class="ArticlesPost.MainPage"
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:my="clr-namespace:ArticlesPost.Views">
<Grid
x:Name="LayoutRoot"
Background="White">
<my:Author
HorizontalAlignment="Left"
Margin="80,121,0,0"
x:Name="author1"
VerticalAlignment="Top"
/>
</Grid>
</UserControl>
Now Build and run the code.
Did you notice the problem .Unlike the WCF Ria Service Series which we completed
, In this case our table Author is Associated with other tables such as Article
and Payroll .
That is quite easily visible here .
We need to do some manual work here to get things right . I promise just a
little . Its simple enough we should not allow the columns to be autogenerated
, instead specify what columns you need to generate . Also note that by default
the AutoGenerateColumns is True .
Modify the DataGrid code as follows :
<sdk:DataGrid
AutoGenerateColumns="False"
Height="200"
HorizontalAlignment="Left"
ItemsSource="{Binding
ElementName=authorDomainDataSource,Path=Data}"
Margin="0,52,0,0"
Name="authorDataGrid"
RowDetailsVisibilityMode="VisibleWhenSelected"
VerticalAlignment="Top"
Width="400">
<sdk:DataGrid.Columns>
<sdk:DataGridTextColumn
Binding="{Binding
Path=AuthorID}"
Header="AuthorID"></sdk:DataGridTextColumn>
<sdk:DataGridTextColumn
Binding="{Binding
Path=FirstName}"
Header="FirstName"></sdk:DataGridTextColumn>
<sdk:DataGridTextColumn
Binding="{Binding
Path=LastName}"
Header="LastName"></sdk:DataGridTextColumn>
</sdk:DataGrid.Columns>
</sdk:DataGrid>
Now Build and run.
We have completed one View . In the next post we will continue with the next
View Payroll .