Hi Guyz,
I am not able to set the focus to another tabitem with in a TabControl. Some times focus works; but most of the time not working. The code is
private void dgClmPaymentScheduleInstallment_MouseDoubleClick(object sender, MouseButtonEventArgs e) { DependencyObject source = e.OriginalSource as DependencyObject; if (source == null) return; DataRecordPresenter drp = Infragistics.Windows.Utilities.GetAncestorFromType(source, typeof(DataRecordPresenter), true) as DataRecordPresenter; if (drp == null) return; if (drp.Record != null) { drp.Record.IsSelected = true; drp.IsActive = true; DataRecord myRecord = drp.DataRecord; if (myRecord.ParentRecord == null) { LoadDataForEditingPaymentTemplate(); // tabPaymentScheduleTemplate.Focus(); //Keyboard.Focus(tabPaymentScheduleTemplate); } else { window.comPricingElementID = (int)myRecord.Cells["COMPricingElementID"].Value; LoadDataForEditingPaymentSchedule(window.paymentInstallmentID); } } }
Most of the time any of the three focus codes not working. I tried all the three focus codes independently.
What's wrong?
Thanks
Asif Abdulla. A
If the element is in a tab that is not selected then those elements aren't in the visual tree. Maybe you should try calling BringIntoView on the element first and then calling focus on it.