Skip Navigation LinksHome / Community & Support / Code Library / WPF > General and Integration Projects > RadOutlookBar and Prism regions

Not answered RadOutlookBar and Prism regions

Feed from this thread
  • Lionel avatar

    Posted on Aug 10, 2011 (permalink)

    Hello I am actually evaluating Telerik RadControls for WPF for future projects. These projects will use Prism as a modular application guidance.

    So far I have been playing with the OutlookBar without Prism but now I try to integrate it in a modular application I encounter some bugs. My test application is a classical Prism architecture composed of a WPF application for the Shell, an Infrastructure assembly for shared functionalities and of 2 module assemblies.

    The shell is only containing the OutlookBar which holds a Prism region. Then when the modules are loaded, they both publish a view containing only a OutlookBarItem in the OutlookBar region. For this, everything works fine and the views are displayed in the OutlookBar. The problem is that it is clearly improperly displayed. Firstly the items are really thin, you can nearly click on them. Secondly they are displaying their Header property only when collapsed in the overflow bar. Thirdly when you click on one of them the display behavior starts to be really strange, I cannot really describe it. I checked all my bindings with WPF Inspector and Snoop and everything is fine on this side.

    Maybe I am missing something crucial in the usage of OutlookBar within Prism.

    I attached a project reproducing this bug and 2 screenshots so you can have a look at it.

    Steps to reproduce:
    1. Launch the application
    2. Click on the OutlookBarItem to see what is happening

    Thanks for your help.

    Reply

  • Tina Stancheva Tina Stancheva admin's avatar

    Posted on Aug 11, 2011 (permalink)

    Hello Lionel,

    I believe in your case it would be best to create a custom region adapter to control the behavior of the RadOutlookBar control as a region. Please have a look at this forum thread and the project attached there. I hope it will get you in the right direction.

    Regards,
    Tina Stancheva
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

    Reply

  • Lionel avatar

    Posted on Aug 11, 2011 (permalink)

    Hello Tina,

    So I tried to use the RegionAdapter you provided but in my case it did not worked. Actually I saw that in the Shell you were overriding the ItemContainerStyle of the RadOutlookBar to make the Title and Header property binding comply with the view model located in a module! I found this kind of surprising, especially for a MVVM pattern. Therefore I have no idea how I can display the correct title in my application without using this "trick".

    Also I saw that the RegionAdapter creates new instances of RadOutlookBarItem to nest the view and then manually add it to the RadOutlookBar items. Don't the control should do that by itself?

    What do you think?

    Reply

  • Lionel avatar

    Posted on Aug 12, 2011 (permalink)

    Thinking again about this issue, I realise that we do not really have choice but edit the ItemContainerStyle, I bet this is simply where the limits of MVVM ends.

    On the other hand, the RegionAdapter should definitely not have to create manually a RadOutlookBarItem. Actually, if I add any UI control in a RadOutlookBar or even a TabControl, it will generate a RadOutlookBarItem, or a TabItem in the other case, that will wrap my UI control. So why should we reimplement an internal mechanism of the original control in a RegionAdapter? I am pretty sure we can make this adapter cleaner and more respectful of the WPF/Prism concepts.

    What do you think?

    Reply

  • Lionel avatar

    Posted on Aug 12, 2011 (permalink)

    I finally modified the RegionAdapter you provided and now it works like a charm without manually reproducing some mechanisms internal to the RadOutlookBar. Here is the adapter I made:

    public class RadOutlookBarRegionAdapter : RegionAdapterBase<RadOutlookBar>
        {
            public RadOutlookBarRegionAdapter(IRegionBehaviorFactory regionBehaviourFactory)
                : base(regionBehaviourFactory) { }
     
            protected override void Adapt(IRegion region, RadOutlookBar regionTarget)
            {
                region.ActiveViews.CollectionChanged +=
                new NotifyCollectionChangedEventHandler((sender, args) =>
                {
                    switch (args.Action)
                    {
                        case NotifyCollectionChangedAction.Add:
                            foreach (UserControl view in args.NewItems)
                            {
                                regionTarget.Items.Add(view);
                            }
                            break;
     
                        case NotifyCollectionChangedAction.Remove:
                            foreach (UserControl view in args.NewItems)
                            {
                                regionTarget.Items.Remove(view);
                            }
                            break;
                    }
                });
            }
     
            protected override IRegion CreateRegion()
            {
                return new AllActiveRegion();
            }
        }

    Also I attached a project demonstrating the use of this adapter.
    The adapter may not be perfect and probably need some tweaks but for now it works pretty well. I am sure it could help other people in the same situation.
    Attached files

    Reply

  • Tina Stancheva Tina Stancheva admin's avatar

    Posted on Aug 16, 2011 (permalink)

    Hello Lionel,

    Thank you for your feedback and for sharing your code. I changed this ticket type to Code Library so that the community can take advantage of your approach. I also updated your Telerik account for your input on the matter.

    All the best,
    Tina Stancheva
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Code Library / WPF > General and Integration Projects > RadOutlookBar and Prism regions