RadTabControl - lazily load declaritive content

1 Answer 270 Views
TabControl
Scott Waye
Top achievements
Rank 2
Iron
Iron
Veteran
Scott Waye asked on 28 Jun 2021, 05:29 PM

Hi,

In Silverlight I believe the RadTabControl will lazily load the content of a RadTabControl when the RadTabItems are declared in the Xaml.  In WPF I seems to eager load all the items on loading the control.  Is it possible to configure the RadTabControl to only instantiate the RadTabItem content when the tab is selected to improve performance?


Thanks

1 Answer, 1 is accepted

Sort by
0
Martin Ivanov
Telerik team
answered on 30 Jun 2021, 11:34 AM

Hello Scott,

All tab item contents in the RadTabControl are read by the XAML parser in case they are defined in XAML. However, the only the selected tab's content will be added into the visual tree. Then when you select another tab, the previously selected content is removed from the visual tree and the new one is added. You can change this behavior using the IsContentPreserved property of the control. In this case, the contents are added to the visual tree on the first selection of the corresponding tab and then only their Visibility changes.

There is no option to change the default loading of the XAML defined contents. What you can try for the performance optimization is to set the SupressSelectedContentTemplateReapplying property of the RadTabControl to True.

Regards,
Martin Ivanov
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Scott Waye
Top achievements
Rank 2
Iron
Iron
Veteran
commented on 30 Jun 2021, 05:22 PM

That would be ok, but it executes the bindings as well as you can see from this stack

Demurrage.dll!Demurrage.Claim.InterfaceMessagesViewModel.InterfaceMessagesViewModel(Demurrage.ViewModels.ClaimSummaryViewModel claimSummaryViewModel) Line 19 C#
> Demurrage.dll!Demurrage.ViewModels.ClaimSummaryViewModel.InterfaceMessagesViewModel.get() Line 1138 C#
[Native to Managed Transition]
[Managed to Native Transition]
PresentationFramework.dll!MS.Internal.Data.PropertyPathWorker.GetValue(object item, int level) Unknown
PresentationFramework.dll!MS.Internal.Data.PropertyPathWorker.RawValue(int k) Unknown
PresentationFramework.dll!MS.Internal.Data.PropertyPathWorker.RawValue() Unknown
PresentationFramework.dll!MS.Internal.Data.ClrBindingWorker.RawValue() Unknown
PresentationFramework.dll!System.Windows.Data.BindingExpression.TransferValue(object newValue, bool isASubPropertyChange) Unknown
PresentationFramework.dll!System.Windows.Data.BindingExpression.Activate(object item) Unknown
PresentationFramework.dll!System.Windows.Data.BindingExpression.AttachToContext(System.Windows.Data.BindingExpression.AttachAttempt attempt) Unknown
PresentationFramework.dll!System.Windows.Data.BindingExpression.MS.Internal.Data.IDataBindEngineClient.AttachToContext(bool lastChance) Unknown
PresentationFramework.dll!MS.Internal.Data.DataBindEngine.Task.Run(bool lastChance) Unknown
PresentationFramework.dll!MS.Internal.Data.DataBindEngine.Run(object arg) Unknown
PresentationFramework.dll!MS.Internal.Data.DataBindEngine.OnLayoutUpdated(object sender, System.EventArgs e) Unknown
PresentationCore.dll!System.Windows.ContextLayoutManager.fireLayoutUpdateEvent() Unknown
PresentationCore.dll!System.Windows.ContextLayoutManager.UpdateLayout() Unknown
PresentationCore.dll!System.Windows.ContextLayoutManager.UpdateLayoutCallback(object arg) Unknown
PresentationCore.dll!System.Windows.Media.MediaContext.InvokeOnRenderCallback.DoWork() Unknown
PresentationCore.dll!System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks() Unknown
PresentationCore.dll!System.Windows.Media.MediaContext.RenderMessageHandlerCore(object resizedCompositionTarget) Unknown
PresentationCore.dll!System.Windows.Media.MediaContext.RenderMessageHandler(object resizedCompositionTarget) Unknown
WindowsBase.dll!System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate callback, object args, int numArgs) Unknown
WindowsBase.dll!System.Windows.Threading.ExceptionWrapper.TryCatchWhen(object source, System.Delegate callback, object args, int numArgs, System.Delegate catchHandler) Unknown
WindowsBase.dll!System.Windows.Threading.DispatcherOperation.InvokeImpl() Unknown
WindowsBase.dll!MS.Internal.CulturePreservingExecutionContext.CallbackWrapper(object obj) Unknown
System.Private.CoreLib.dll!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state) Unknown
WindowsBase.dll!MS.Internal.CulturePreservingExecutionContext.Run(MS.Internal.CulturePreservingExecutionContext executionContext, System.Threading.ContextCallback callback, object state) Unknown
WindowsBase.dll!System.Windows.Threading.DispatcherOperation.Invoke() Unknown
WindowsBase.dll!System.Windows.Threading.Dispatcher.ProcessQueue() Unknown
WindowsBase.dll!System.Windows.Threading.Dispatcher.WndProcHook(System.IntPtr hwnd, int msg, System.IntPtr wParam, System.IntPtr lParam, ref bool handled) Unknown
WindowsBase.dll!MS.Win32.HwndWrapper.WndProc(System.IntPtr hwnd, int msg, System.IntPtr wParam, System.IntPtr lParam, ref bool handled) Unknown
WindowsBase.dll!MS.Win32.HwndSubclass.DispatcherCallbackOperation(object o) Unknown
WindowsBase.dll!System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate callback, object args, int numArgs) Unknown
WindowsBase.dll!System.Windows.Threading.ExceptionWrapper.TryCatchWhen(object source, System.Delegate callback, object args, int numArgs, System.Delegate catchHandler) Unknown
WindowsBase.dll!System.Windows.Threading.Dispatcher.LegacyInvokeImpl(System.Windows.Threading.DispatcherPriority priority, System.TimeSpan timeout, System.Delegate method, object args, int numArgs) Unknown
WindowsBase.dll!MS.Win32.HwndSubclass.SubclassWndProc(System.IntPtr hwnd, int msg, System.IntPtr wParam, System.IntPtr lParam) Unknown
[Native to Managed Transition]
[Managed to Native Transition]
WindowsBase.dll!System.Windows.Threading.Dispatcher.PushFrameImpl(System.Windows.Threading.DispatcherFrame frame) Unknown
WindowsBase.dll!System.Windows.Threading.Dispatcher.PushFrame(System.Windows.Threading.DispatcherFrame frame) Unknown
WindowsBase.dll!System.Windows.Threading.Dispatcher.Run() Unknown
PresentationFramework.dll!System.Windows.Application.RunDispatcher(object ignore) Unknown
PresentationFramework.dll!System.Windows.Application.RunInternal(System.Windows.Window window) Unknown
PresentationFramework.dll!System.Windows.Application.Run() Unknown
Demurrage.dll!Demurrage.App.Main() Unknown
Martin Ivanov
Telerik team
commented on 02 Jul 2021, 10:13 AM

Because of the default XAML parsing behavior of the framework, the data binding and loading of the elements cannot be disabled while the tab contents are added in XAML. One way to improve the performance is to use the data binding support of the control. This will allow you to set the ItemsSource and then define the tab views in DataTemplates which will be loaded only when the corresponding content (the model) is assigned to the content presenter.
Scott Waye
Top achievements
Rank 2
Iron
Iron
Veteran
commented on 02 Jul 2021, 12:29 PM

Ok, thanks for the info.
Tags
TabControl
Asked by
Scott Waye
Top achievements
Rank 2
Iron
Iron
Veteran
Answers by
Martin Ivanov
Telerik team
Share this question
or