RadComboBox within DataForm did not apply changes after committed

10 posts, 0 answers
  1. Seree
    Seree avatar
    29 posts
    Member since:
    Sep 2006

    Posted 09 Jun 2010 Link to this post

    Hi there,

    First of all, I would like to thank you to Telerik to create a wonderful ComboBox, it helps me much on my application development career.

    Anyway, I have a question regards on using RadComboBox within DataForm.

    Here is my case.
    - I have a Product Details form created using DataForm of Silverlight Toolkit.
    - I have a field ProductCategoryId which is a foreign key linking to ProductCategories table which I would like to let use pick it up from ComboBox, I want to reuse it so I build a Custom Control named "ProductCategoryLookup" and put RadComboBox within it. Here is the XAML for the Custom Control.
    <Grid x:Name="LayoutRoot" Background="White" HorizontalAlignment="Stretch" Width="Auto"
            <riaControls:DomainDataSource AutoLoad="True" Height="0" LoadedData="ddsLookup_LoadedData" Name="ddsLookup" QueryName="GetInventoryItemCategoriesByCompanyIdQuery" Width="0"
                    <my1:MasterContext /> 
            <Controls1:RadComboBox Name="ComboLookup" IsEditable="True" IsTextSearchEnabled="True" TextSearchMode="StartsWith" ItemsSource="{Binding ElementName=ddsLookup, Path=Data}" DisplayMemberPath="Title" SelectedValuePath="InventoryItemCategoryId" HorizontalContentAlignment="Stretch" UseLayoutRounding="True">             

    - Here is the code behind after the Custom Control. I just added a Dependency Property to be able to do data binding.
    public static readonly DependencyProperty SelectedIdProperty = DependencyProperty.Register( 
                new PropertyMetadata(SelectedIdChanged)); 
            public int SelectedId 
                    return (int)this.GetValue(SelectedIdProperty); 
                    this.SetValue(SelectedIdProperty, value); 
            private static void SelectedIdChanged(object sender, DependencyPropertyChangedEventArgs args) 
                var me = sender as InventoryItemCategoryLookup; 
                me.ComboLookup.SelectedValue = args.NewValue; 
                if (me.SelectedValueChanged != null) 

    - In the DataForm, I put my Custom Control into the data field like this.
    <dataFormToolkit:DataField Grid.Row="3" Grid.Column="0" Label="Category" LabelPosition="Auto"
                                        <my:InventoryItemCategoryLookup SelectedId="{Binding Path=CategoryId, Mode=TwoWay, NotifyOnValidationError=True, ValidatesOnExceptions=True}" Behaviors:DataSourceBehavior.Enable="True"

    - When I run the application, it displays a correct value.

    However, I got 2 problems...
    1. When I change the value by selecting another option from the RadComboBox, the DataForm didn't notified that the data was changed. The Commit button will never appear until I changed another data fields.
    2. When I click on the Commit button, all changes were saved except the value of my Custom Control which is RadComboBox.

    So, I think there 2 problems are caused by the same reason that custom control did not notify changes to the DomainDataSource.

    I also found some thread that got the same problem with me even he place a RadComboBox directly into the DataForm but I cannot find out a solution within the thread.

    From my further research, I found someone talking about Behavior, I also found an example from some thread here about DataSourceBehavior but I cannot figure out how can I apply it in my case. Here is the code I found.
    using System.Windows; 
    using System.Windows.Controls; 
    using System.Threading; 
    using System.Windows.Threading; 
    using System.Collections.ObjectModel; 
    namespace ComboDataForm 
        public class DataSourceBehavior 
            public static bool GetEnable(DependencyObject obj) 
                return (bool)obj.GetValue(EnableProperty); 
            public static void SetEnable(DependencyObject obj, bool value) 
                obj.SetValue(EnableProperty, value); 
            public static readonly DependencyProperty EnableProperty = 
                DependencyProperty.RegisterAttached("Enable", typeof(bool), typeof(DataSourceBehavior), new PropertyMetadata(OnEnabledPropertyChanged)); 
            private static void OnEnabledPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs args) 
                // This will simulate the delay in the getting of the data source from a service 
                DispatcherTimer timer = new DispatcherTimer(); 
                timer.Tick += (a, b) => 
                    // Case #1 
                    //var values = new IntVal[]  
                    //    new IntVal() { ID = 1Text = "one" }, 
                    //    new IntVal() { ID = 2Text = "two" }, 
                    //    new IntVal() { ID = 5Text = "five" }, 
                    //    new IntVal() { ID = 10Text = "ten" } 
                    //(d as ItemsControl).ItemsSource = values
                    // Case #2 
                    var values = new IntVal[]  
                        new IntVal() { ID = 5Text = "five" }, 
                        new IntVal() { ID = 1Text = "one" }, 
                        new IntVal() { ID = 2Text = "two" }, 
                        new IntVal() { ID = 10Text = "ten" } 
                    var source = new ObservableCollection<IntVal>(); 
                    (d as ItemsControl).ItemsSource = source
                    foreach (var v in values) 
                timer.Interval = new System.TimeSpan(0, 0, 0, 0, 500); 

    So I would like to ask here for some hints or suggestion.

    Keep up the great works!

    Thank you and best regards,
    Seree Woradechjamroen
  2. Seree
    Seree avatar
    29 posts
    Member since:
    Sep 2006

    Posted 10 Jun 2010 Link to this post


    Could you please have a look at it and give me some suggestion ASAP as I am working on a prototype and it need to be done?

    Or do I need to submit the ticket? (I am a paid subscription customer)

    Thank you and best regards,
    Seree W.
  3. Valeri Hristov
    Valeri Hristov avatar
    2252 posts

    Posted 10 Jun 2010 Link to this post

    Hi Seree,

    I cannot see where you are updating the source data object - if you are not updating it, the DataForm has no way to determine if it was changed or not. A support ticket with a simple application that can be used to observe the problem would be of great help.

    Valeri Hristov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  4. Seree
    Seree avatar
    29 posts
    Member since:
    Sep 2006

    Posted 10 Jun 2010 Link to this post

    Hi Valeri,

    Thanks for your quick response.

    I am updating the data through the RadComboBox within my Custom Control which reside in the DataForm.
    Anyway, after I changed the value in RadComboBox, the DataForm did not received a change notification from my Custom Control.
    It is the same as I put a RadComboBox in to the DataForm.

    I am finding how can I make my Custom Control or RadComboBox to notify a changed to the DataForm but still cannot figure it out.

    Do you have any suggestion?

    Thank you and best regards,
    Seree W.
  5. Seree
    Seree avatar
    29 posts
    Member since:
    Sep 2006

    Posted 11 Jun 2010 Link to this post

    Just to update...

    If I put the RadComboBox within the DataForm, I can make it works correctly now. So, the problem is not actually came from RadComboBox but my Custom Control itself.

    Anyone have a suggestion or guideline how to create a data bound Custom Control? (The problem is that I can't make the the data binding to work correctly)

    Best regards,
    Seree W.
  6. Seree
    Seree avatar
    29 posts
    Member since:
    Sep 2006

    Posted 13 Jun 2010 Link to this post

    Just to update.

    Finally, I found how to handle this situation, it is not a false of RadComboBox but how I create a Custom Control.

    Thanks anyway,
    Seree W.
  7. Bob
    Bob avatar
    1 posts
    Member since:
    Apr 2010

    Posted 21 Jun 2010 Link to this post

    Hello Seree,

    Being new to Silverlight development, I have found many issues with using the combo box in the way you described above. I have come across the Telerik controls since many people have found them to solve this problem. Would it be to much to ask if you could share the code with me as to how you came about to fix the problem?

    Here is my scenario, I have two tables:

    ProductGroupID (FK)


    ProductGroupID (PK)

    I would like to have a grid that shows me all the Products in the database with the Group column a combobox that shows me the ProductGroupName for that Product and not the ProductGroupID. If I want to change it, I would want to select the ProductGroupName from the combobox.

    Do you have any suggestions because I have been unable to get this to work with Silverlight 4 and Visual Studio 2010.

    Thank you in advance
  8. Almond
    Almond avatar
    43 posts
    Member since:
    Feb 2011

    Posted 15 Feb 2011 Link to this post

    Hello Bob,

    Were you able to find a solution in your inquiry below. I have the same dilemma :(

    Hope you can share your solution.

    Thanks and good day once again.
  9. Peter
    Peter avatar
    37 posts
    Member since:
    Dec 2011

    Posted 29 Jan 2014 Link to this post

    I have the same problem!

    I'm using a RadComboBox within a DataFormComboBoxFiled, which is auto-generated.

    I'm not doing anything special, but changing the selected value  of the ComboBox just will not enable the Commit button of the DataForm.
  10. Yana
    Yana avatar
    4604 posts

    Posted 03 Feb 2014 Link to this post

    Hi Peter,

    This is quite an old thread and it seems that the discussed scenario is different than the one you're describing.  If you're using RadDataForm for Silverlight, please post the question in the corresponding forum:

    Thank you for the understanding.

    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
Back to Top