Thursday, July 31, 2008

Infragistics TabGroupPane Region Adapter for CompositeWPF (Prism) Applications

This is my first contribution (more to come soon) to the WPF world ! A Region Adapter for the Infragistics TabGroupPane* component.

For those not familiar with Composite WPF:
  • A View is a unit that encapsulates a portion of the UI and is kept as decoupled as possible from other parts of the application.
  • A Region is a container that holds Views to be displayed.
  • A Region Adapter adapts a Region to a WPF Control, thus displaying the actual contents of the associated Views.

I started adapting TabGroupPane since it was an immediate need for a prototype I am coding. As the prototype continues evolving, I think I'll be end up adapting other components of xamDockManager and maybe others of Net Advantage for WPF.

*TabGroupPane is a component of xamDockManager - A powerful docking and layout
management control for WPF (http://www.infragistics.com/dotnet/netadvantage/wpf/xamdockmanager.aspx)


Usage

  • Register the TabGroupPane region adapter mapping in the Bootstrapper as shown in the code below:

    protected override RegionAdapterMappings ConfigureRegionAdapterMappings()
    {

    RegionAdapterMappings mappings = base.ConfigureRegionAdapterMappings();

    mappings.RegisterMapping(typeof(TabGroupPane), new TabGroupPaneRegionAdapter());

    return mappings;

    }

  • Add the TabGroupPane to your Shell/View XAML (you have to declare the namespace on the top of the file):

    <igDock:XamDockManager Grid.Row="1" x:Name="dockManager">
    <igDock:SplitPane >
    <igDock:TabGroupPane Name="TabGroupPane1"
    cal:RegionManager.RegionName="{x:Static infrastructure:RegionNames.Editor}"/>
    </igDock:SplitPane>
    <
    /igDock:XamDockManager>

  • To add views, just obtain the region and call the Add method as you do with other regions:

    IRegion editorRegion = RegionManager.Regions[RegionNames.Editor];
    ITabGroupPaneMetadata tabGroupPaneMetadata = new TabGroupPaneMetadata();
    tabGroupPaneMetadata.Header=”Header #1”;

    MyView view = new MyView();

    view
    .SetTabGroupPaneMetadata(tabGroupPaneMetadata);

    editorRegion.Add(
    view);

    editorRegion.Activate(
    view);


    Notice that
    in the preceding code I am also setting the TabGroupPaneMetadata attached property to the view (via Extensions Methods). This attached property is used by the TabGroupPaneRegionAdapter to set the Header property displayed on the associated TabGroupPane item.

Disclaimer
This code is provided "AS IS" with no warranties, and confers no rights.


Download
You can get the TabGroupPaneRegionAdapter by downloading the latest change set of the CompositeWPF Contrib source control.

7 comments:

Anonymous said...

Great work. Just what i have been looking for.
I have been trying to do the same for docking component from Devcomponents Maybe with you example I will manage :-)

Regards,

H.

Anonymous said...

Great, i'll try this out. Let us now if you come up with something more.

/Cake

Anonymous said...

What are the usings here. ?

Anonymous said...

Thank you!!

I hope we will see more Infragistics extensions from you.

Regards,
hh

Anonymous said...

Hello,

I'm using CompositeWPFContrib.Composite.Wpf.Infragistics region extension in my project. I can open the view as a docking windows or floating windows or tabbed windows in my project. But I'm not sure how to switch the view inside the docking windows.

For example: If I open the View1, it will be opened as a tab. Lets say there is a button in View1. If I click that button from View1, I want to switch the View1 to View2.

Note: View1 and View2 are not from same module.

How can I achieve this?

Tom P said...

Have you extended this to grant access to the closing events or other meta data properties such that we could pin the controls by default etc...

Vivek said...

Hi,
I am using ViewNavigation. So register my views using RegionManager.RequestNavigation("[regionname]",new URI("[viewnametoresolvefromunity]"),URIKind.Relative)

Can you please tell me how do i set the header in this case? Because i don't create any instance(its actually directly resolved from unity) i am not sure how to this. Any help will be much appreciated. Thanks