This is a migrated thread and some comments may be shown as answers.
Dynamic Content in Tab
1 Answer 121 Views
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
John asked on 11 Sep 2008, 09:14 PM
I would like to set the URL of another XAML page that should be the content of the tab control.

How do I setup the control to diaplay a page, instead of inline content?

How do I change the URL of the content to another XAML user control at runtime?


1 Answer, 1 is accepted

Sort by
Telerik team
answered on 12 Sep 2008, 07:11 AM
Hi John,

We are currently working on a control that will make loading external pages easier.

For the time being this logic is application-specific. For example, loading only xaml (no code-behind) can be done with the XamLReader:

var myContent = (FrameworkElement)XamlReader.Load("My xaml string"); 

where the xaml string can be loaded from various sources: web service, resources, external .xap, etc.

If you want to change the content to a UserControl (page) then you need to create an instance of the page once you know its type:

var typeToInstantiate = typeof(Page);  
var myContent = (Page)Activator.CreateInstance(typeToInstantiate); 

The application logic may involve downloading an external .xap file, browsing through its contents for an assembly, then loading it with AssemblyPart and finally instantiating one of its types.

Changing the contents of the currently selected TabItem will change the contents of the TabControl

If the items of the TabControl are TabItems, you can access them through the items property, otherwise you can use the container generator:

   RadTabItem tabitem = tabControl.ItemContainerGenerator.ContainerFromIndex(tabControl.SelectedIndex) as RadTabItem;  
   tabitem.Content = ... 

Hopefully you will be able to achieve what you need.

Come back to us if you have any more questions,

Best wishes,
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Asked by
Top achievements
Rank 1
Answers by
Telerik team
Share this question