views:

78

answers:

0

I am using following markup on Silverlight page:


    <Grid x:Name="lytEmpForm" Margin="8">
     <Grid.RowDefinitions>
      <RowDefinition Height="Auto"/>
      <RowDefinition Height="Auto"/>
      <RowDefinition Height="Auto"/>
      <RowDefinition Height="Auto"/>
     </Grid.RowDefinitions>
     <Grid.ColumnDefinitions>
      <ColumnDefinition Width="0.20*"/>
      <ColumnDefinition Width="0.50*"/>
      <ColumnDefinition Width="0.30*"/>
     </Grid.ColumnDefinitions>
     <sdk:Label x:Name="lblEmpno" Margin="8" Content="Empno:"/>
     <sdk:Label x:Name="lblEname" Margin="8" Content="Ename:" Grid.Row="1"/>
     <sdk:Label x:Name="lblSal" Margin="8" Content="Salary:" Grid.Row="2"/>
     <sdk:Label x:Name="lblDeptno" Margin="8" Content="Deptno:" Grid.Row="3"/>
     <TextBox x:Name="txtEmpno" Grid.Column="1" Margin="8" Height="24" Text="{Binding Empno, Mode=TwoWay}"/>
        <TextBox x:Name="txtEname" Grid.Column="1" Margin="8" Grid.Row="1" Height="24" Text="{Binding Path=Ename}"/>
        <TextBox x:Name="txtSal" Grid.Column="1" Margin="8" Grid.Row="2" Height="24" Text="{Binding Path=Sal, Mode=TwoWay}"/>
        <TextBox x:Name="txtDeptno" Grid.Column="1" Margin="8" Grid.Row="3" Height="24" Text="{Binding Path=Deptno, Mode=TwoWay}"/>
     <Button x:Name="btnSearch" Content="Search" Margin="8" Height="24" Grid.Column="2" Width="50" HorizontalAlignment="Left"/>
    </Grid>

Private oCtxt As New BusinessLib.Web.EmpMgrDomainSvc

Public Sub New()
    InitializeComponent()

    Me.dgEmp.ItemsSource = oCtxt.emps
    oCtxt.Load(oCtxt.GetEmpsQuery())

End Sub

Private Sub btnSearch_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles btnSearch.Click
    Dim oEmp = oCtxt.emps.Where(Function(p) p.empno = Me.txtEmpno.Text).FirstOrDefault
    If oEmp Is Nothing Then
        MessageBox.Show("Employee not found", "Message", MessageBoxButton.OK)
    Else
        Me.lytEmpForm.DataContext = oEmp
        Me.txtEmpno.DataContext = oEmp
        Me.txtEname.DataContext = oEmp
    End If
End Sub

None of the following statements work in the above code:

        Me.lytEmpForm.DataContext = oEmp
        Me.txtEmpno.DataContext = oEmp
        Me.txtEname.DataContext = oEmp

But, when I debug, I could see "oEmp" filled with respective values in their respective properties. I am completely missing something somewhere.

While I read that I can accomplish above simply using DomainDatasource/DataForm, I am just expermenting with plain and simple classic binding in Silverlight together with WCF RIA services.

Can anyone help me on this?

thanks