This is a migrated thread and some comments may be shown as answers.

RadOutlookBar as a Prism region

7 Answers 194 Views
OutlookBar
This is a migrated thread and some comments may be shown as answers.
Greg
Top achievements
Rank 1
Greg asked on 15 Jun 2011, 03:58 PM
Hello all! I'm currently evaluating Telerik's tools for a green field LoB project. Skipping to the nitty gritty, I'm currently trying to use the RadOutlookBar as a Prism region. I've followed the instructions here, but the solution feels a little, well... cheesy. In particular, I'm not really grooving on this recommendation...

public void Initialize()
{
   // Register views here.
   this.regionManager.RegisterViewWithRegion("OutlookBarRegion", () =>
   {
      return new ModuleAView().OutlookBarItem;
   };
}

See, in our app, the shell contains an OutlookBar and the idea is that modules will register views that contain an OutlookBarItem. Okay, so the solution above works, but it's really just a work-around. Our issue is that this forces us to handle views that contain OutlookBarItems in a wholly different manner than all of our other views. Blech. Ideally, I should be able to simply register the view without the lambda silliness.

So any ideas on alternatives? Do I need to write a Region Adapter that will enumerate each OutlookBarItem in each item found in the NewItems list when items are added to a region? Does Telerik have a suggestion?

-Greg

7 Answers, 1 is accepted

Sort by
0
Greg
Top achievements
Rank 1
answered on 15 Jun 2011, 05:10 PM
Now that I think about it, I don't think writing a region adapter will work. If the module has a view like this...

<UserControl x:Class="MyCompany.ModuleA.Views.ViewA"
   mc:Ignorable="d">
   <Grid>
      <telerik:RadOutlookBarItem x:Name="moduleAOutlookBarItem">
         <telerik:RadTreeView>
            <telerik:RadTreeViewItem Header="1.0 Something">
               <telerik:RadTreeViewItem Header="1.1 Sub-Something" />
            </telerik:RadTreeViewItem>
          </telerik:RadTreeView>
      </telerik:RadOutlookBarItem>
   </Grid>
</UserControl>

...and we were to try and write our Adapt() method as such...

protected override void Adapt(IRegion region, RadOutlookBar regionTarget)
{
// When the view collection changes...
      region.Views.CollectionChanged += (sender, e) =>
      {
         // Based on the action that caused the event...
         switch (e.Action)
         {
            // If elements were added...
            case NotifyCollectionChangedAction.Add:
 
               foreach (DependencyObject dependencyObject in e.NewItems)
               {
                  IEnumerable<RadOutlookBarItem> outlookBarItems = dependencyObject.FindChildren<RadOutlookBarItem>();
 
                  foreach (RadOutlookBarItem outlookBarItem in outlookBarItems)
                  {
                     // BZZZZTTT!!! Yeah, the outLookBarItem already has a parent. No love.
                     regionTarget.Items.Add(outlookBarItem);
                  }
               }
 
               // Etc...

Now we're treading into murky waters with the concept of "reassigning" the RadOutlookBarItem's parent. Blech.

Am I just way, way off base here?

-Greg
0
Accepted
Tina Stancheva
Telerik team
answered on 20 Jun 2011, 06:53 PM
Hello Greg,

I am not sure if I understand your issue correctly. You said that in this solution the OutlookBar views that contain OutlookBarItems are handled in different manner than all of your other views, but can you please elaborate on how you expect to handle the views?

I also attached a sample project illustrating a different approach for using the RadOutlookBar control in a PRISM scenario - a custom RegionAdapter is defined for the RadOutlookBar control. It might help you.

Regards,
Tina Stancheva
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Greg
Top achievements
Rank 1
answered on 21 Jun 2011, 04:23 PM
Tina,

That does the trick! The RadOutlookBarRegionAdapter was the key.

Our issue was with where the instructions showed registering the view with the lambda. We have an abstract base class for IModule that enumerates the types in the assembly and will either register a view with a region or register a type with the container based on attributes decorating the view's code-behind. Without the custom region adapter, we'd be forced to handle the view containing the RadOutlookBarItem some other way to accommodate the lambda. Fortunately, your region adapter eliminates that issue.

We all did a facepalm when we saw the Adapt() code (it seems so obvious now).

Thanks!
-Greg
0
Igor
Top achievements
Rank 1
answered on 11 Feb 2013, 10:37 AM
Hello,
I've used your sample projects in order to populate OutlookBar with OutlookbarItems dynamically via PRISM. Unfortunately, with the latest update of Telerik WPF RadControls libraries (RadControls_for_WPF_2012_3_1129_Dev_hotfix, ver. 2012.3.1129.40), Ive come across problem with initial minimized state of all OutlookbarItems. (this issue has been discussed already, see http://www.telerik.com/community/forums/wpf/outlookbar/radoutlookbar-all-items-minimized-in-new-version.aspx). Can you please verify the status and possibly provide me with the solution? My goal is to have all OutlookbarItems visible by default (not in minimized state).

PS: In the sample project, I've used Windows8 theme

Thank you

Igor Menovsky
0
Pavel R. Pavlov
Telerik team
answered on 14 Feb 2013, 10:01 AM
Hi Igor,

You can try setting the ActiveItemsCount property of the RadOutlookBar.

Regards,
Pavel R. Pavlov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Gianpaolo
Top achievements
Rank 1
answered on 10 Feb 2014, 02:20 PM
Hello,

I'm having a hard time trying to adapt the given example to use IActiveAware view models. I suspect that SelectorItemsSourceSyncBehavior is broken when used with a RadOutlookBar. What i did:

1) I implemented IActiveAware in MainViewModel. At this point the IsActive property is being set to true for each view added since RadOutlookBarRegionAdapter returns AllActiveRegion as IRegion implementations. But that's not ideal, since only the selected item should be marked as active according to the default region adapter implementation for a tab control.
I tried to return a SingleActiveRegion instead, but that break the example since now the ActiveViews collection changed event now fires a reset signal, which can't be handled as the other events (both old items and new items are null, ActiveViews and Views are empty).

2) Removed the custom adapter to use the default one, adapted the views to be RadOutlookBarItem. Now the IActiveAware is being ignored and is always set to false.

Is this expected behavior? Am i doing something wrong? I mean i could handle the SelectionChanged event manually and indeed it works, but it feels like it should be done automatically  by prism (and in fact it does in my production code with a similar control which i'm trying to replace with RadOutlookBar).
0
Pavel R. Pavlov
Telerik team
answered on 13 Feb 2014, 12:22 PM
Hello Gianpaolo,

Please note that the provided example demonstrates a possible usage of PRISM in combination with our RadOutlookBar control. Extending that example actually is out of our support scope. This is why I recommend asking in other community driven online resources, like StackOverflof, for a solution. Please note that the RadOutlookBar control is actually an ItemsControl and in this case you need to use it in your custom project.

After a brief research I found out a post that may be helpful in your particular case.

Regards,
Pavel R. Pavlov
Telerik

Check out the new Telerik Platform - the only modular platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native apps. Register for the free online keynote and webinar to learn more about the Platform on Wednesday, February 12, 2014 at 11:00 a.m. ET (8:00 a.m. PT).

Tags
OutlookBar
Asked by
Greg
Top achievements
Rank 1
Answers by
Greg
Top achievements
Rank 1
Tina Stancheva
Telerik team
Igor
Top achievements
Rank 1
Pavel R. Pavlov
Telerik team
Gianpaolo
Top achievements
Rank 1
Share this question
or