Dynamic Content in Tab

2 posts, 0 answers
  1. John
    John avatar
    3 posts
    Member since:
    Aug 2008

    Posted 11 Sep 2008 Link to this post

    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?

  2. Miroslav
    Miroslav avatar
    922 posts

    Posted 12 Sep 2008 Link to this post

    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.
Back to Top