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

Prism Region in RadTabItem ContentTemplate

1 Answer 152 Views
TabControl
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
David asked on 26 Sep 2016, 02:27 PM

Hi. I have a RadTabControl, wich ContentTemplate is a static resource with a DataTemplate like this:

 

        <DataTemplate x:Key="TabItemContentTemplate" >
            <ContentControl prism:RegionManager.RegionName="{Binding RegionName}"/>
        </DataTemplate>

My item view model has a Header property and a RegionName property. All I want is to know the exactly moment all the templates are applied in the RadTabControl, so I can call the RegionManager to create a view inside.

I've tried RadTabControl.Loaded and may others, also have tried to locate ContentPresenter named ContentElement and attach to the Loaded event, but even there the content control is not yet created.

 

Any ideas? Thanks in advance.

 

David.

1 Answer, 1 is accepted

Sort by
0
Kiril Vandov
Telerik team
answered on 29 Sep 2016, 07:53 AM
Hello David,

The Template of the RadTabControl is applied just right after the OnApplyTemplate method is called, for WPF the Loaded event is fired after that initialization and can access all of the TabControlTemplate parts from in the event. However that does not guarantee that the Content of the SelectedtabItem will be inserted. That is because the RadTabControl selects its first item(if the IsDefaultItemSelected property is set, its default value is true) and that logic is executed inside a Dispatcher in the LoadedEvent. If you want to intersect the content insertion placing the logic inside a Dispatcher in the loaded event of the RadTabControl will do the trick and the content will be loaded.
I am not sure about your implementation for Prism for the RadTabControl and the need to inject such views manually when you can have the Prism do the work for you. We have an SDK sample for a PRISM implementation with our RadTabControl and a CustomRegionAddapter for it in our online repository.

I hope this information helps.

Kind regards,
Kiril Vandov
Telerik by Progress
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
Tags
TabControl
Asked by
David
Top achievements
Rank 1
Answers by
Kiril Vandov
Telerik team
Share this question
or