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

Explicit UpdateSource in Radcombobox?

1 Answer 157 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
gokulnath
Top achievements
Rank 1
gokulnath asked on 12 Apr 2011, 01:20 PM
Hello Telerik,
                       I have one clarification in radcombobox..
How to get Values when Focus is in RadcomboBox?
<telerik:RadComboBox IsEditable="True" Text="{Binding Path=District,Mode=TwoWay, UpdateSourceTrigger=LostFocus, NotifyOnValidationError=True, ValidatesOnDataErrors=True, ValidatesOnExceptions=True}" Margin="103,5,33,0" Name="rcboDistrict" TabIndex="8" FontSize="11" IsDropDownOpen="False" Grid.Column="2" Grid.Row="1" VerticalAlignment="Top" Height="24" />
In XAML i am setting UpdateSourceTrigger=LostFocus..
if suppose focus is in Radcombobox and client will save the detail.That time radcombobox value not getting..

in this project i am using radmenu for displaying Save,Modify Items..If suppose Focus is in TextBox mean i am Updating manually from the following Code..
this.Dispatcher.BeginInvoke(new Action(() =>
            {
                  if (Keyboard.FocusedElement.GetType() == typeof(TextBox))
                  {
                     BindingExpression exprLastName = ((TextBox)Keyboard.FocusedElement).GetBindingExpression(TextBox.TextProperty);
                  exprLastName.UpdateSource();
             }
               //Implementation
 }));

My problem is i want to Update radComboBox also
The above code i am changing RadComboBox instead of TextBox..But its not working...
I find Debugging in runtime
KeyBoard.FocusedElement.GetType() value is PickerTextBox... But focus is in radComboBox

I don't know why pickerTextBox Comes instead of radcomboBox ?
How to update radCombobox value? any suggestions are more welcome...
(I know UpdateSourceTrigger=PropertyChanged .Here i don't want Bcoz i am doing validation in Business object level.
if suppose i am using Property changed each and every character its goes validation thats why i am avoiding..)

1 Answer, 1 is accepted

Sort by
0
Pana
Telerik team
answered on 18 Apr 2011, 07:26 AM
Hello,

I would not recomment the following approach but I can find other solution for your problem.

RadComboBox has several controls inside its ControlTemplate - TextBox (PickerTextBox), ToggleButton (the drop down button), Popup, Clear Button etc. When you click in the RadComboBox you actually focus the PickerTextBox inside. To get the RadComboBox that the picker belongs to you can use the ParentOfType<RadComboBox>() extension method from Telerik.Windows.Controls. For example:

UIElement pickerTextBox = Keyboard.FocusedElement.GetType() as UIElement;
if (pickerTextBox != null)
{
    RadComboBox combo = pickerTextBox.ParentOfType<RadComboBox>();
    if (combo != null)
    {
        // Do some work with the combo
    }
}


All the best,
Pana
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
Tags
ComboBox
Asked by
gokulnath
Top achievements
Rank 1
Answers by
Pana
Telerik team
Share this question
or