Archive for the 'Composite Application Library' Category

Interested in migrating from Composite Application Block (CAB) to CompositeWPF (Prism)? Check our new guidance

As Diego Poza announced in his post, we have just published a new guidance to help CAB developers familiarize themselves with the Composite Application Guidance by comparing the main components of both libraries.

Let’s take a look at the guidance content index:

image

Because the Composite UI Application Block and the Composite Application Guidance are targeted to build composite applications, they have similar core concepts. These core concepts have different implementations. The following figure compares the implementation of the core concepts.
 image

Want more?

Download the Composite Application Guidance for Composite UI Application Block Developers from Codeplex.

Feedback

We really want your feedback on this guidance, so feel free to give us your feedback on the discussion board.

Enjoy!

Silverlight & Composite Application Guidance (Prism): Spike published

Weeks ago we shipped the Composite Application Guidance for WPF and with the Prism team we started to spike around the migration of the Composite Application Library to Silverlight 2 Beta 2. The good news is that yesterday we published that spike. (A ’spike’ is a small and quickly developed sample application in order to mitigate some risks).

After downloading and decompressing the latest change set of the source control, you will find a new folder named spikes that contains the Composite Application Library migrated to Silverlight. As you may imagine, there were many challenges that we had to address in order to make it “work”  (Rob Eisenberg wrote two articles describing differences between WPF and Silverlight that you might want to check: There’s some darkness in your silver light and Silverlight Problems That Affect Me).

Note: The migration is not complete, we used the spike to have a perspective of the challenges.

 

Modularity

Module loading in Silverlight is very different from WPF, so this was a challenge. We continued spiking on different approaches, but those spikes are not uploaded to Codeplex yet.

Regarding the module enumerators, System.Configuration is not supported by Silverlight current version, so we are using a new XML file module enumerator (not published either).

Regions

In WPF, the RegionManager attached property value gets inherited by the elements in the visual tree. This cannot be done in Silverlight due to the lack of the FrameworkPropertyMetadataOptions.Inherits option. However, we have found a workaround for this issue.

If you want to declare regions in XAML, you have to create an application resource to store the RegionManager instance, so it can be used by the views. This can be done in the Bootstrapper, as shown in the code below:

protected override void ConfigureContainer()
{
   base.ConfigureContainer(); IRegionManager regionManager = Container.Resolve<IRegionManager>();
   Application.Current.Resources.Add(“RegionManager”, regionManager);
}

And the view has to explicitly set the RegionManager attached property to the resource created previously.

<ItemsControl x:Name=”MainRegionControl” cal:RegionManager.RegionName=”MainRegion” cal:RegionManager.RegionManager=”{StaticResource RegionManager}” />

Events

Events has been migrated successfully, however, the unit tests are still a challenge because of the differences in threading between Silverlight and WPF. One difference we found, is that if you are subscribing to an event using weak references, for this reason you can only use public methods as delegates (lambdas, anonymous delegates or private methods won’t work) because of security restrictions enforced by Silverlight.

Commands

As you might know, the support for commands is missing in Silverlight. This is really bad news, considering that big part of our guidance talk about using Commands for communication between the modules and from the view.

I’m not going into deep details on this because Julian Dominguez published a great post explaining how to use commands in Silverlight.

Download

You can get the spike by downloading the latest change set of the CompositeWPF source control.

Notes

  • We didn’t ship the Unity Application Block, so I recommend you to see Michael Sync’s post in order to have Unity working on Silverlight.
  • In order to run the Unit tests, check Jeff Wilcox’post.

Feedback  / Contributions

Feel free to give us your feedback on the discussion board. If you want to contribute with the CompositeWPF project, check the CompositeWPF contrib. community site.

Enjoy!

CompositeWPF (Prism) Contrib Latest Additions (2008-07-26)

These are the latest extensions added to the CompositeWPF Contrib community project:

  • Extended Module Loader Service (contributed by Willem Meints). The extended module loader service can be used to load modules on demand. When the module loader service loads a module it will check if the module being loaded is actually installed and install it from the original installation source.
  • Module Status Service (contributed by Willem Meints). The module status service can be used to retrieve a list of modules and their status (loaded or unloaded). This is particular useful when you want to show the user of your CompositeWPF application what modules are available to the application and which modules are actually active at this moment. image
    For more information about this service, see Module status service for CompositeWPF.
  • OutlookBar control and region adapter.
     
    For more information about this control, see Use the OutlookBar in your CompositeWPF (Prism) Applications.
Where I can find the documentation of the extensions added to the project?

To check the documentation of the extensions added so far, please visit the Documentation page in the community site.

To learn more about other additions to the project, see this post.

Enjoy!

Use the OutlookBar in your CompositeWPF (Prism) Applications

Two years ago, together with Matias Woloski we wrote the Outlook Bar for the Composite Application Block (CAB). I can say that it was a popular workspace, with more than 19,000 downloads!. Now that we shipped CompositeWPF (Prism), some people at the CompositeWPF community started asking for the OutlookBar for CompositeWPF, so Julian Dominguez, Matias Woloski and me decided to spend some time and create the Composite WPF version.

clip_image001

 

Usage

First of all, you have to register the region adapter mapping in the Bootstrapper as shown in the code below:

protected override RegionAdapterMappings ConfigureRegionAdapterMappings()
{
    IEventAggregator eventAggregator = Container.Resolve<IEventAggregator>();

    RegionAdapterMappings mappings = base.ConfigureRegionAdapterMappings();

    mappings.RegisterMapping(typeof(OutlookBarControl), new OutlookBarControlRegionAdapter(eventAggregator));

    return mappings;
}

Now you can add the OutlookBarControl to your Shell/View XAML (you have to declare the namespace on the top of the file):

<Controls:OutlookBarControl 
       cal:RegionManager.RegionName="{x:Static infrastructure:RegionNames.OutlookBarRegion}"/>
                
To add views, just obtain the region and call the Add method as you do with other regions: 

IRegionManager regionManager = Container.Resolve<IRegionManager>();
MyView view = new MyView();
OutlookBarControl.SetOutlookBarMetadata(view, new OutlookBarMetadata
    {
        Title = "Mail",
        Payload = "MyPayload"
    });

regionManager.Regions[RegionNames.OutlookBarRegion].Add(view);
regionManager.Regions[RegionNames.OutlookBarRegion].Activate(view);

As you may noticed, in the preceding code we are also setting the OutlookBarMetadata attached property to the view. This attached property is used by the control template and by the OutlookBarControlRegionAdapter.

  • In the control template we are using the Title property in the OutlookBarControl header and in the buttons.
  • In the region adapter we are using the payload to publish the OutlookBarEvent. This event is published every time you select a view.

The OutlookBarMetadata serves a similar purpose the OutlookBarSmartPartInfo served in the CAB version.

Disclaimer

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

Acknowledgments

The control template is based on this article on CodeProject.

Download

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

 

Stay tuned, we are working on v1.1 of the OutlookBar.

CompositeWPF (Prism) Contrib Latest Additions

A week ago we shipped the Composite Application Guidance for WPF and many people (including me) started to contribute in the CompositeWPF Contrib community project and to play with the guidance.

Let’s explore the latest additions added to the CompositeWPF Contrib project.

  • CompositeModuleEnumerator. The CompositeModuleEnumerator makes it possible to combine several module enumerator instances into one module enumerator. This makes it easier for developers to for example combine both fixed modules and modules loaded through the ConfigurationModuleEnumerator.
    image
    For more information about the CompositeModuleEnumerator, see Combining module enumerators in CompositeWPF.
  • ToolBarPanelRegionAdapter. This adapter adapts control of type System.Windows.Controls.Primitives.ToolBarPanel and derived classes.
  • Visual Studio Templates. The goal of these templates is to help users start with the Composite WPF project
    For more information about the Visual Studio Templates, see Composite Application Guidance for WPF Visual Studio Templates.

I’ve been also reorganizing the folder structure of the project, so if you download the latest change set you will find the following structure:

image

If you want to contribute to the project, please follow the Sign Up Process.

Enjoy!

Composite Application Guidance for WPF Visual Studio Templates

As you may know, in the June 2008 release of the Composite Application Guidance for WPF we are not shipping a guidance package. So, I created two Visual Studio Templates to help you to start with the creation of a solution using the Composite Application Guidance for WPF.

clip_image002[4]

You will get two kind of solution/project templates

image

After creating a solution using the templates, you must create in the folder where solution its located a folder named Library and copy to it the following assemblies (otherwise the solution created is not going to compile):

  • Microsoft.Practices.Composite.dll
  • Microsoft.Practices.Composite.Wpf.dll
  • Microsoft.Practices.Composite.UnityExtensions.dll
  • Microsoft.Practices.Unity.dll
  • Microsoft.Practices.ObjectBuilder2.dll

Download the Composite Application Guidance for WPF templates (zip file with a VSI inside)

Any feedback is welcome. Enjoy!

Composite Application Guidance for WPF (Prism) June 2008 Released

I’m proud to announce that we have just released the Composite Application Guidance for WPF. I want to thank to the Composite WPF Team. It was really great being part of this release.

Let’s see what this release is about.

 

What is Composite Application Guidance for WPF?

The Composite Application Guidance for WPF is a set of guidance designed to help you more easily manage the complexities you may face when building enterprise-level Windows Presentation Foundation (WPF) client applications. This guidance will help you design and build flexible WPF client applications using loosely coupled, independently evolvable pieces that work together and are integrated into the overall application.

For more information, see Composite Application Guidance - What is it?.

 

What is in this release?
Downloads
Documentation
Getting Started / Installation Instructions
Community Site

To give feedback, get assistance or download additional content please visit our community site.

Contributions

If you want to contribute with this project, please visit our contrib community site.

Knowledge Base

We have created a Knowledge Base to categorize and organize blogs posts, CodePlex pages, CodePlex posts, etc that can be valuable for the community.

Known Issues

In this page you will find the list of known issues of the Composite Application Guidance for WPF.

Feedback

Feel free to give us your feedback on the discussion board. If you see issues, please post them to the Issue Tracker.

 

For more information of this new release, see Composite Application Guidance is Live.

Enjoy this new release.

Composite Application Guidance for WPF (Prism) Release Candidate Published

Last Friday, we published the release candidate version of the Composite Application Guidance for WPF (formerly known as Prism). In this release you will find a Reference Implementation, a Hands on-Lab, several spikes we did, some QuickStarts, the Composite Application Library and documentation.

The following picture maps the composite application concepts to the how-to topics in the documentation.

image

Note: Before installing this release, see the installation instructions.

For more information about this release, you can check the following posts:

Prism: New drop published

A new drop of Prism has been published last Thursday. Among other things, in this drop we refactored the Bootstrapper by extracting common functionality into a base class named UnityPrismBootstrapper located in the Prism.UnityContainerAdapter project.

For example, the Bootstrapper of the RI now looks like:

public class StockTraderRIBootstrapper : UnityPrismBootstrapper { private readonly EntLibPrismLogger _prismLogger = new EntLibPrismLogger(); protected override IModuleEnumerator GetModuleEnumerator() { return new StaticModuleEnumerator() .AddModule(typeof(NewsModule)) .AddModule(typeof(MarketModule)) .AddModule(typeof(WatchModule), MarketModule) .AddModule(typeof(PositionModule), MarketModule, NewsModule); } protected override IPrismLogger PrismLogger { get { return _prismLogger; } } protected override void ConfigureContainer() { Container.RegisterType<IShellView, Shell>(); base.ConfigureContainer(); } protected override DependencyObject CreateShell() { ShellPresenter presenter = Container.Resolve<ShellPresenter>(); IShellView view = presenter.View; view.ShowView(); return view as DependencyObject; } }

Pretty simple, don’t you think?

Also, we’ve included a new IModuleEnumerator implementation named StaticModuleEnumerator that facilitates the task of statically adding modules to your application. You can see an usage of this new IModuleEnumerator implementation in the GetModuleEnumerator method showed before.

If you want more information about this release, please see the release notes. You can download the drop from here.

BTW - The team has been writing about Prism, so I encourage all to take a look at the following posts:

About Presentation Model

About decoupled communication with Prism

As always, we invite your feedback.
Technorati Profile

Prism How-To: Provide metadata to a view that was placed into a region

If you downloaded our fourth drop probably you may have noticed that we have removed the IMetadataInfo and IMetadataInfoProvider classes. (See Julian's post for more info about this change).

In the Prism Forum some people are asking how to provide metadata to the view now that the IMetadataInfo class has been removed, so in this post I will explain how to do it.

Imagine that you have a TabRegion named MainRegion in your Shell and you want to add a view to it.

<TabControl Name=”Tab” Prism:RegionManager.Region=”MainRegion”>

After you do this

regionManagerService.GetRegion(MainRegion).Add(new View())

you will see something like the following picture

Looks good, but… we don't have a header, so let's see how to do it

  • Create a HeaderModel class

    namespace PrismTabHeader { using System.Windows; public class HeaderModel : DependencyObject { public static readonly DependencyProperty HeaderInfoProperty = DependencyProperty.Register(HeaderInfo, typeof(string), typeof(HeaderModel)); public string HeaderInfo { get { return (string)GetValue(HeaderInfoProperty); } set { SetValue(HeaderInfoProperty, value); } } } }

    This class contains a HeaderInfo dependency property.

  • Update the view by adding the Model property.
    public HeaderModel Model { get { return DataContext as HeaderModel; } set { DataContext = value; } }

  • Create a new style named HeaderStyle in the Shell.

 

<Window.Resources> <Style TargetType=”{x:Type TabItem} x:Key=”HeaderStyle”> <Setter Property=”Header” Value=”{Binding RelativeSource={RelativeSource Self}, Path=Content.DataContext.HeaderInfo} /> </Style> </Window.Resources>

This style is going to be applied to TabItem elements and is saying that the value of the property Header is going to binded to Content.DataContext.HeaderInfo where Content is the view.

Note: You can also expose a HeaderInfo property in the view and change the binding path to Content.HeaderInfo.

  • Replace the TabControl definition of your Shell with the following code

 

 

<TabControl Name=”Tab” Prism:RegionManager.Region=”MainRegion” ItemContainerStyle=”{StaticResource HeaderStyle} />

As you may see we are setting the ItemContainerStyle dependency property to affect the appearance of the elements that contain the data items. In this case, the style is going to be applied to all TabItem elements within the scope the style is defined in.

 

  • Set the Model to the view before adding it to the region
    View view = new View(); view.Model = new HeaderModel() { HeaderInfo = My Header }; region.Add(view);

If you run the application now you will see the header.

Hope this helps.

Next Page »