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

RadTabControl validation doesn't work with unselected tab

1 Answer 62 Views
TabControl
This is a migrated thread and some comments may be shown as answers.
Prashant
Top achievements
Rank 1
Prashant asked on 06 Nov 2019, 08:03 AM

Hi All,

I am using RadTabControl and validation is working only if tab is selected. i.e. updating UI only for selected tab and not others.

I have a RadTabControl control with three RadTabItem. Every tabitem contains usercontrol with own view model.

For all user controls, i have used  IDataErrorInfo for validation. From main control, manually i am triggering validation using notifyproperty change i.e.  RaisePropertyChanged(string.Empty).

This is working fine only if tab is selected. validation is executing properly on other tabs but UI is not updating

Control Structure:

MainVM.cs

      - TabControl1VM = new TabControl1ViewModel();

      - TabControl2.VM = new TabControl2ViewModel();

 

MainControl.xaml

  <telerik:RadTabControl  >
            <telerik:RadTabItem  Header="Location" DataContext="{Binding TabControl1VM}" >
                <telerik:RadTabItem.Content >                    
                        <local:TabControl1></local:TabControl1>                    
                </telerik:RadTabItem.Content>
            </telerik:RadTabItem>

            <telerik:RadTabItem Header="Asset Type" DataContext="{Binding TabControl2VM}">
                <telerik:RadTabItem.Content>
                    <local:TabControl2></local:TabControl2>
                </telerik:RadTabItem.Content>
            </telerik:RadTabItem>

 

Any help would be appreciated,

Regards,

Prashant
           

 

 

 

 

1 Answer, 1 is accepted

Sort by
0
Petar Mladenov
Telerik team
answered on 08 Nov 2019, 03:13 PM

Hello Prashant,

By default only the selected RadTabItem's Content is included in the WPF visual tree. The content is set to the Content property of a ContentPresenter located in the RadTabControl's default ControlTemplate. The rest of the Contents of the tabs are not loaded. Validation typically requires invalidating a binding and a binding to kick in properly requires a control / template to be loaded. RadTabControl provides IsContentPreserved property and when set to True, every Content will be added in a separate ContentPresenter , this way preserving visual state. However, the actual load happens on Selection change. So I guess by the time you call RaisePropertyChanged() the UI you need updated in not actually in the UI.

I hope this helps. If not, you can send me more details regarding your scenario and I will be glad to assist  you further.

Regards,
Petar Mladenov
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
TabControl
Asked by
Prashant
Top achievements
Rank 1
Answers by
Petar Mladenov
Telerik team
Share this question
or