This is a migrated thread and some comments may be shown as answers.

RadComboBox behaviour in DataForm

14 Answers 210 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Tweel
Top achievements
Rank 1
Tweel asked on 17 Mar 2010, 12:11 AM
Hello,

I am using the RadComboBox in a DataForm. The SelectedValue binding works much better than the standard one. There are however a couple of issues that are spoiling the implementation for me:
  1. The DataForm is not aware when the RadComboBox SelectedValue has changed, to enable the "Commit" button that will save the change permanently. (EDIT: fixed by expliclitly calling changed event on property - not required for normal Text Boxes)
  2. The RadComboBox appearance is a lot different to the other controls on the form. The enabled property must be enforced using control.IsEnabled = !(e.Mode == DataFormMode.ReadOnly); and the background/border/foreground do not match the other controls. Copying the BorderBrush/Background/Foreground properties from another control (after enabling/disabling) does not work either.
    I would happily use the RadMaskedTextBox for consistency in appearance but the latest version breaks the application when embedded on a DataForm with MaskType="None".
Presumably it would be a common scenario to use these controls on a DataForm. Can anybody please provide a few tips to explain a getaround for these issues?
Thanks

14 Answers, 1 is accepted

Sort by
0
Helen
Top achievements
Rank 2
answered on 28 Jan 2011, 01:40 AM
I don't know if you are still struggling with a RadComboBox in a DataForm, but I am.

One way to make sure it gets enabled/disabled is to wrap it in a <toolbox:datafield></toolbox:datafield> pair. Apparently this is the only way the DataForm knows that it should enable/disable a control. I would have thought that it would do so for anything it contains.

hope this helps,

Helen
0
George
Telerik team
answered on 02 Feb 2011, 10:02 AM
Hi Helen,

 
Please, refer to the following forum thread- http://www.telerik.com/community/forums/silverlight/combobox/radcombobox-within-dataform-did-not-apply-changes-after-committed.aspx

I hope this helps.

All the best,
George
the Telerik team
Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
0
Vasile
Top achievements
Rank 1
answered on 05 Mar 2011, 09:12 PM
Dear Telerik team,

I have the same problem: If I use RadComboBox in a DataForm, it will not Enable/Disable according with the state of the DataForm. Even if the rest of TextBox fields are disabled the RadComboBox(s) are still enabled and I can update the associated fields even if I did not put the DataForm in edit mode (with the pencil).

If I use standard ComboBox it will work correctly in sync with TextBox(s) from the DataForm.

The RadComboBox is nested into a DataField control

 

<toolkit:DataField Grid.Row="1" Grid.Column="0" Label="Priority">
  <!-- This works correctly
  <ComboBox ItemsSource="{Binding VM.SharedViewModel.IntensityLevels, Source={StaticResource viewModel}}"
     DisplayMemberPath="Name"
     SelectedValuePath="Id"
     SelectedValue="{Binding Priority,Mode=TwoWay}">
  </ComboBox>
  -->
    
  <!-- This will not work correctly with respect to Enable/Disable in sync with DataForm State -->                   
  <telerik:RadComboBox
      ItemsSource="{Binding VM.SharedViewModel.IntensityLevels, Source={StaticResource viewModel}}"
      DisplayMemberPath="Name"
      SelectedValuePath="Id"
      SelectedValue="{Binding Priority,Mode=TwoWay}">
  </telerik:RadComboBox>
</toolkit:DataField>

 

 

 

 

Any hints?

Thanks,
Vasile M

0
Helen
Top achievements
Rank 2
answered on 05 Mar 2011, 09:24 PM
Vasile, I have the same problem with a lot of controls. For instance, I have a DataForm that contains a StackPanel with two controls in it, and I have to manually enable/disable them according to the state of the form.
0
Tweel
Top achievements
Rank 1
answered on 05 Mar 2011, 09:38 PM
Hi Vasile,

For some reason the controls do not support the DataForm mode.
I had to catch the ContentLoaded event and manually set the Enabled state of each Telerik control.
In case you havnt used it:
bool isEditing = !(ElemForm.Mode == DataFormMode.ReadOnly);
  
RadGridView crusherGrid = (RadGridView)ElemForm.FindNameInContent("crusherGrid");
if (crusherGrid != null) crusherGrid.IsEnabled = isEditing;

My other problem in the OP was with the appearance compared to the non-Telerik controls. RadMaskedTextBox did not work with MaskType="None" at that point, so Microsoft text boxes mixed with Telerik controls was not a good look.

Good luck

Paul
0
Vasile
Top achievements
Rank 1
answered on 05 Mar 2011, 11:06 PM
Thank you for your fast feedback,

Meanwhile I had an eye into the implementation of DataForm, using Reflector, and I am afraid we are stuck. In the DataForm at some points the code is explicitly looking for some standard control types like TextBox and ComboBox, the use of these control types is hardcoded into the DataForm control...pretty strange.

I am going now to explore if I can do anything to extend that with a derived DataForm control and maybe overriding something

Vasile
0
Vasile
Top achievements
Rank 1
answered on 05 Mar 2011, 11:13 PM
Paul

Thank you for your suggestion, I will consider it, I am not very entusiastic with this solution because I try to stick as much as possible with MVVM in my project, and this typeof workaround just makes things go away.

Vasile
0
Helen
Top achievements
Rank 2
answered on 05 Mar 2011, 11:49 PM
Vasile, you can download the source code of the Dataform here: http://silverlight.codeplex.com/SourceControl/list/changesets

It might be easier to change the source code rather than inherit from it. I know there are issues either way.

Another gotcha with the DataForm is that sometimes the EditEnded event gets called twice, which also can cause the app to error out. I ended up with mine by keeping track of what the user was doing (Add, Edit, Delete, None) and if they were editing, what was the current item, and checked with the edit ended whether the selected item was the current item. I note from the forums that this is a known (intermittent) issue.

Another good reason to vote for Telerik adding their own DataForm to the control suite!
0
Vasile
Top achievements
Rank 1
answered on 05 Mar 2011, 11:55 PM
I guess I found the reason why RadComboBox does not work correctly in DataForm

Seems that DataForm & DataField controls are trying to put controls in ReadOnly mode by setting one of the two properties:
First IsReadOnly property is searched and if exists is set accordingly, if this one is not found then it goes further and search IsEnabled property and sets it accordingly.

Now RadComboBox has IsReadOnly but the behavior of it would be pretty different than I would have expect.
If you set IsReadOnly = true for RadComboBox then you will not be able to type custom value in the text box, but you will be able to select value from the dropdown, also the visual state of the control will not change in any way.

I think this is not the right behavior for IsReadOnly state for the control.

Is this a bug in RadComboBox control or is it by design? My feeling is that it is a bug otherwise it is only "half" readonly.
Would appreciate a Telerik feedback on this.

Thanks,
Vasile
0
Vasile
Top achievements
Rank 1
answered on 06 Mar 2011, 12:01 AM
Helen,

Thank you for the input, 
It just confirms me that I am not alone in my fight with DataForm, I was fighting hours and hours to get the DataForm properly set to generate the events and commit edit & new in the right way, The control is beautiful when you see very simple demos on the net, but it is a nightmare when you try to put it to more specific needs in a complex setup like the one I have (RIA + PRISM + MVVM + Telerik Docking).

Vasile
0
Tweel
Top achievements
Rank 1
answered on 06 Mar 2011, 12:02 AM
Hi,

FWIW this is some TelerikAdmin advice that I was given in response to a support ticket, in March 2010.  A couple of interesting bits.

1) The Toolkit's DataForm control is able to recognize only a few standard controls - TextBox, Selector (ListBox and ComboBox), ToggleButton (CheckBox and RadioButton) and DatePicker. Since the standard Selector control cannot be inherited by third parties, we use our own implementation, which unfortunately is not recognized by the DataForm, hence it does not respond to SelectedValue/SelectedItem changes in RadComboBox.
2) The situation is the same as above - the DataForm searches its DataField controls for elements that have IsReadOnly or IsEnabled properties (in this order) and since RadComboBox's has a IsReadOnly property that has slightly different behavior than the standard TextBox, the form uses it instead of IsEnabled, hence providing unexpected results. I would recommend using both EditTemplate and ReadOnlyTemplate, where you could precisely configure the controls in the DataFields.

0
Vasile
Top achievements
Rank 1
answered on 06 Mar 2011, 12:05 AM
Hello Paul,

Appreciate your input, little bit more work, but ReadOnlyTemplate is going to fix my problem.

Thank you,
Vasile
0
Helen
Top achievements
Rank 2
answered on 06 Mar 2011, 12:21 AM
Vasile, that is exactly my experience with the DataForm as well. I have spent untold hours painfully trying to figure out how to make it work, what order the events happen, etc. Alas, you have to use the ContentLoaded event to handle controls like the ComboBox because they go out of scope during various states of the DataForm, even if you only have one template defined.

All the examples are so easy that it makes it look like using it is a no-brainer. hah!

I just hope enough people vote for Telerik adding it to their control suite, so that we will eventually have one from them.

You can vote for it here: http://www.telerik.com/support/pits.aspx#/public/silverlight/1608
0
Mark
Top achievements
Rank 1
answered on 08 Jun 2011, 09:38 PM
Count me in ...
Thankfully I've only spent a full day and finally found this thread.
Tags
ComboBox
Asked by
Tweel
Top achievements
Rank 1
Answers by
Helen
Top achievements
Rank 2
George
Telerik team
Vasile
Top achievements
Rank 1
Tweel
Top achievements
Rank 1
Mark
Top achievements
Rank 1
Share this question
or