hi!
I developed a UserControl with a RadComboBox and RadMaskedTextBox, snippet code is like this:
into my main project I declared UserControl like this:
I declared 2 dependency properties into My UserControl named ValorTipoDocumento and ValorNumeroDocumento in this way:
I hope so far It could have be understood!! I try to make clear at the most.
I bounded my UserControl to the radGridView by using the two properties I created to refelct changes in both way.
Note:
When I navigate into RadGridView (I mean, selectedItemChanged is fired), UserControl reflects the changes in right way (I mean radComboBox and radMaskedTextBox). PROBLEMS begin when I select other item into radComboBox and I change text into radMaskedTextBox, and I try to update source data in RadGridView, by using:
ctrDatosPersona.GetBindingExpression(ctlIdentificacionPersona.ValorTipoDocumentoProperty).UpdateSource();
ctrDatosPersona.GetBindingExpression(ctlIdentificacionPersona.ValorNumeroDocumentoProperty).UpdateSource();
Data are null. RadGridView shows empty data into corresponding cells. I try to do a trace and ctrDatosPersona doesn't return selected values and text changed, in fact, returns {} for ValorTipoDocumento and nothing for ValorNumeroDocumento. The way I realized about this was by tracing ValidationRules values.
I don't know how to do to radGridView reflects changes from my UserControl.
It's urgent, any helps I appreciate
I developed a UserControl with a RadComboBox and RadMaskedTextBox, snippet code is like this:
<cl:ctlIdentificacionPersona xmlns:cl="clr-namespace:App_ControlLibrary" xmlns:tb="clr-namespace:App_EntityLibrary.Tablas;assembly=App_EntityLibrary" xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation" mc:Ignorable="d" x:Name="UserControl" Height="62" Width="368"> <Grid x:Name="pnlBaseControl" RenderTransformOrigin="0.5,0.5" Margin="0,0,5,0" Height="59" VerticalAlignment="Top"> <TextBlock x:Name="lblTipoDocumento" Text="{x:Static cl:resxIdentificacionPersona.lblTipoDocumento}" VerticalAlignment="Top" Height="21" Margin="5,4,170,0" Padding="68,2,0,5"/> <telerik:RadComboBox x:Name="cbxTipoDocumento" SelectedValuePath="CA001" DisplayMemberPath="CA002" IsEditable="False" HorizontalAlignment="Left" Margin="5,26,0,0" VerticalAlignment="Top" Height="27" Width="190" TabIndex="0"/> <TextBlock x:Name="lblNumeroDocumento" Text="{x:Static cl:resxIdentificacionPersona.lblNumeroDocumento}" Margin="199,4,0,0" VerticalAlignment="Top" Height="21" Padding="41,2,0,5" HorizontalAlignment="Left" Width="118"/> <telerik:RadMaskedTextBox x:Name="fmtNumeroDocumento" Margin="197,26,0,0" TabIndex="1" Mask="n0" MaskType="Numeric" HorizontalContentAlignment="Right" Height="27" VerticalAlignment="Top" HorizontalAlignment="Left" Width="120"/> <telerik:RadButton x:Name="btnBuscar" Margin="321,16,0,2" HorizontalAlignment="Left" Width="39" Background="{x:Null}" BorderBrush="{x:Null}"> <Image Source="/App_ControlLibrary;component/Imagenes/Lupa.png" Stretch="Uniform" Height="35" Width="34" /> </telerik:RadButton> </Grid></cl:ctlIdentificacionPersona>into my main project I declared UserControl like this:
<Grid><cl:ctlIdentificacionPersona x:Name="ctrDatosPersona" Tag="TABLA_PRINCIPAL" Height="Auto" Margin="1,3.02,5,1.73" Width="Auto"><cl:ctlIdentificacionPersona.ValorTipoDocumento> <Binding ElementName="grdGridConsulta" Path="SelectedItem.CA003" Mode="TwoWay" UpdateSourceTrigger="Explicit" Converter="{StaticResource ConvertidorGeneralValores}"> <Binding.ValidationRules> <cl:ReglaDatoRequerido MensajeError="{lr:RecursoIdioma IDRecurso=msjErrorDatoRequeridoTipoDocumento, TipoRecursoIdioma=PADRE}" ValidationStep="ConvertedProposedValue"/> </Binding.ValidationRules> </Binding>
</cl:ctlIdentificacionPersona.ValorTipoDocumento>
<cl:ctlIdentificacionPersona.ValorNumeroDocumento> <Binding ElementName="grdGridConsulta" Path="SelectedItem.CA004" Mode="TwoWay" UpdateSourceTrigger="Explicit" Converter="{StaticResource ConvertidorGeneralValores}"> <Binding.ValidationRules> <cl:ReglaDatoRequerido MensajeError="{lr:RecursoIdioma IDRecurso=msjErrorDatoRequeridoNumeroDocumento, TipoRecursoIdioma=PADRE}" ValidationStep="ConvertedProposedValue"/> </Binding.ValidationRules> </Binding></cl:ctlIdentificacionPersona.ValorNumeroDocumento>
</cl:ctlIdentificacionPersona>
</Grid>I declared 2 dependency properties into My UserControl named ValorTipoDocumento and ValorNumeroDocumento in this way:
using System;using System.Collections;using System.Collections.Generic;using System.Collections.ObjectModel;using System.Data;using System.Text;using System.Text.RegularExpressions;using System.Threading;using System.Windows;using System.Windows.Controls;using System.Windows.Data;using System.Windows.Documents;using System.Windows.Input;using System.Windows.Media;using System.Windows.Media.Imaging;using System.Windows.Navigation;using System.Windows.Shapes;using System.ComponentModel;using System.Configuration;using Telerik.Windows.Controls;using Telerik.Windows.Controls.MaskedTextBox;using Kernel.Recursos;using App_EntityLibrary;using App_EntityLibrary.Tablas;using System.Event;namespace App_ControlLibrary{ public class ctlIdentificacionPersona : UserControl { #region Variables private RadComboBox cbxTipoDocumento; private RadMaskedTextBox fmtNumeroDocumento; private RadButton btnBuscar; .... public static readonly DependencyProperty ValorNumeroDocumentoProperty = DependencyProperty.Register("ValorNumeroDocumento", typeof(object), typeof(ctlIdentificacionPersona), new FrameworkPropertyMetadata(new PropertyChangedCallback(ValorNumeroDocumentoPropertyChanged))); [Description("Valor contenido en el Número de Documento")] 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))); [Description("Valor Seleccionado en la lista")] public object ValorTipoDocumento { get { return GetValue(ValorTipoDocumentoProperty); } set { SetValue(ValorTipoDocumentoProperty, value); } } ... public ctlIdentificacionPersona() { InitComponents(); cbxTipoDocumento = (RadComboBox)this.FindName("cbxTipoDocumento"); fmtNumeroDocumento = (RadMaskedTextBox)this.FindName("fmtNumeroDocumento"); btnBuscar = (RadButton)this.FindName("btnBuscar"); } private static void ValorNumeroDocumentoPropertyChanged(DependencyObject source, DependencyPropertyChangedEventArgs e) { (source as ctlIdentificacionPersona).ActualizarValorNumeroDocumento(e.NewValue); }private void ActualizarValorNumeroDocumento(object value) { fmtNumeroDocumento.Value = value; } private static void ValorTipoDocumentoPropertyChanged(DependencyObject source, DependencyPropertyChangedEventArgs e) { (source as ctlIdentificacionPersona).ActualizarValorTipoDocumento(e.NewValue); }private void ActualizarValorTipoDocumento(object value) { cbxTipoDocumento.SelectedValue = value; }...}I hope so far It could have be understood!! I try to make clear at the most.
I bounded my UserControl to the radGridView by using the two properties I created to refelct changes in both way.
Note:
<Binding ElementName="grdGridConsulta" Path="SelectedItem.CA003" Mode="TwoWay" AND<Binding ElementName="grdGridConsulta" Path="SelectedItem.CA004" Mode="TwoWay"When I navigate into RadGridView (I mean, selectedItemChanged is fired), UserControl reflects the changes in right way (I mean radComboBox and radMaskedTextBox). PROBLEMS begin when I select other item into radComboBox and I change text into radMaskedTextBox, and I try to update source data in RadGridView, by using:
ctrDatosPersona.GetBindingExpression(ctlIdentificacionPersona.ValorTipoDocumentoProperty).UpdateSource();
ctrDatosPersona.GetBindingExpression(ctlIdentificacionPersona.ValorNumeroDocumentoProperty).UpdateSource();
Data are null. RadGridView shows empty data into corresponding cells. I try to do a trace and ctrDatosPersona doesn't return selected values and text changed, in fact, returns {} for ValorTipoDocumento and nothing for ValorNumeroDocumento. The way I realized about this was by tracing ValidationRules values.
I don't know how to do to radGridView reflects changes from my UserControl.
It's urgent, any helps I appreciate