Home > English > DomainDataSource Changes – No more ControlParameter

DomainDataSource Changes – No more ControlParameter

DomainDataSource Changes – No more ControlParameter

I have been slowly going through all of my existing Silverlight 3 modules that used RIA Services on top of Linq2Sql and I have been porting to Silverlight 4 using WCF RIA Services on top of Linq2Entities. One of the things that I encountered is that the ControlParameter is no longer available. This is actually a good thing since you can now accomplish the same thing with Databinding.

Here is an example of some Xaml where I had previously used the ControlParameter object.

<UserControl
    x:Class="SampleView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:riaCtls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Ria.Controls" 
    xmlns:riaData="clr-namespace:System.Windows.Data;assembly=System.Windows.Ria.Controls"
    >
    <Grid x:Name="LayoutRoot">
            
        <riaCtls:DomainDataSource x:Name="dds" QueryName="GetSl_d_DatabasesByAllButUserId">
            <riaCtls:DomainDataSource.QueryParameters>
                <riaData:ControlParameter ParameterName="userId"
                    ControlName="txtUserId"
                    PropertyName="Text" />
            </riaCtls:DomainDataSource.QueryParameters>
        </riaCtls:DomainDataSource>
        <TextBox x:Name="txtUserId" />
        ...
    </Grid>
</UserControl>

Now with the release of WCF RIA Services, you would write your Xaml as shown in the following example:

<UserControl
    x:Class="SampleView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:riaCtls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.DomainServices" 
    >
    <Grid x:Name="LayoutRoot">
            
        <riaCtls:DomainDataSource x:Name="dds" QueryName="GetSl_d_DatabasesByAllButUserId">
            <riaCtls:DomainDataSource.QueryParameters>
                <riaCtls:Parameter ParameterName="userId" 
                    Value="{Binding ElementName=txtUserId, Path=Text}" />
            </riaCtls:DomainDataSource.QueryParameters>
        </riaCtls:DomainDataSource>
        <TextBox x:Name="txtUserId" />
        ...
    </Grid>
</UserControl>

This adds a lot of extensibility and since we are just using databinding, we can now do binding to controls or bind to any property exposed on the ViewModel.

Hope this helps…

About these ads
  1. Johnny
    July 7, 2010 at 6:56 pm | #1

    suck!

    How i make to put a code XAML here?

    • July 8, 2010 at 12:57 am | #2

      Johnny,

      If you want to submit XAML in your comment you must wrap it with the following tag:

      XAML snippet

      It will then look like this:

      <TextBox Text="Hello World" />
      

      Hope that helps….

  2. Layth Hadi
    June 20, 2013 at 11:46 pm | #3

    Thank you …
    all is working for me !

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 193 other followers

%d bloggers like this: