Aldemar

Aldemar

  • NA
  • 2
  • 0

UserControl doesn't get changes

Nov 4 2010 7:15 PM

I developed a UserControl with Telerik products RadComboBox and RadMaskedTextBox, snippet code is like this:

<cl:ctlIdentificacionPersona ...
  x:Name="UserControl" Height="62" Width="368">
  <Grid>
    <telerik:RadComboBox x:Name="cbxTipoDocumento" SelectedValuePath="CA001" DisplayMemberPath="CA002" .../>
    <telerik:RadMaskedTextBox x:Name="fmtNumeroDocumento" .../>
  </Grid>
</cl:ctlIdentificacionPersona>

in my main project I declared UserControl like this:

<Grid>
<cl:ctlIdentificacionPersona x:Name="ctrDatosPersona">
<cl:ctlIdentificacionPersona.ValorTipoDocumento>
  <Binding ElementName="grdGridConsulta" Path="SelectedItem.CA003" Mode="TwoWay" UpdateSourceTrigger="Explicit"">
   <Binding.ValidationRules>
    <cl:ReglaDatoRequerido .../>
   </Binding.ValidationRules>
  </Binding>                    
</cl:ctlIdentificacionPersona.ValorTipoDocumento>
<cl:ctlIdentificacionPersona.ValorNumeroDocumento>
  <Binding ElementName="grdGridConsulta" Path="SelectedItem.CA004" Mode="TwoWay" UpdateSourceTrigger="Explicit"">
   <Binding.ValidationRules>
    <cl:ReglaDatoRequerido .../>
   </Binding.ValidationRules>
  </Binding>
</cl:ctlIdentificacionPersona.ValorNumeroDocumento>
</cl:ctlIdentificacionPersona>
</Grid>

User Control have two dependency properties named ValorTipoDocumento and ValorNumeroDocumento in this way:

  public class ctlIdentificacionPersona : UserControl
  {
    public static readonly DependencyProperty ValorNumeroDocumentoProperty = DependencyProperty.Register("ValorNumeroDocumento", typeof(object), typeof(ctlIdentificacionPersona), new FrameworkPropertyMetadata(new PropertyChangedCallback(ValorNumeroDocumentoPropertyChanged)));
    public object ValorNumeroDocumento
    {
      get { return GetValue(ValorNumeroDocumentoProperty); }
      set { SetValue(ValorNumeroDocumentoProperty, value); }
    }
    public static readonly DependencyProperty ValorTipoDocumentoProperty = DependencyProperty.Register("ValorTipoDocumento", typeof(object), typeof(ctlIdentificacionPersona), new FrameworkPropertyMetadata(new PropertyChangedCallback(ValorTipoDocumentoPropertyChanged)));
    public object ValorTipoDocumento
    {
      get { return GetValue(ValorTipoDocumentoProperty); }
      set { SetValue(ValorTipoDocumentoProperty, value); }
    }

Problem is when is executed into my main project

ctrDatosPersona.GetBindingExpression(ctlIdentificacionPersona.ValorTipoDocumentoProperty).UpdateSource();
ctrDatosPersona.GetBindingExpression(ctlIdentificacionPersona.ValorNumeroDocumentoProperty).UpdateSource();

Validation Rules are execute and I note values getting from UserControl Dependency Property (ValorTipoDocumentoProperty and ValorNUmeroDocumentoProperty) are null, so Grid shows null values into cells.  Setter is working fine, Child Control into UserControl reflects data fine. but problem is when data is requiered outside of UserControl, I mean, Getter. So UpdateSource get null values from USerControl.