FluentRibbon TabItem outsourcing

Apr 5, 2011 at 2:24 PM

Hi,

Is it possible to outsource some of the Fluent TabItems of the RibbonMenu?

In WPF it we can use the <ContentControl> tag

Is there something similar in Fluent:Ribbon?

Thanks

Magnus

Jul 8, 2012 at 7:13 PM

Hi, I'm trying to achieve the same scenario by using a ContentControl inside Ribbon and then setting up each RibbonTabItem as a ViewModel however ContentControl is not of type RibbonTabItem and I can't place the ContentControl inside the Ribbon because of this. Any thoughts? mwolf, have you figured this out?

Jul 9, 2012 at 11:54 AM

Hi bl4kh4k,

 I'm sorry I didn't figure that out. After different tries which all failed I decided to put all the fluent ribbon content in one single .xaml file.

This was really ugly but it was the only way that worked for me.

 

Jul 12, 2012 at 3:59 PM

Hi mwolf,

I have continued to attempt this design, maybe we can work together if your still interested in this approach. I have emailed Daniel who helped create the library but have not received any insight on the scenario as of yet.

What I have currently done is I took the RibbonTabItem and instead of inheriting from Control I made it ContentControl... this removes the error at runtime saying ContentControl is not of type RibbonTabItem... because now RibbonTabItem is a ContentControl.... but now I'm stuck with applying the actual DataTemplate with a GroupBoxes and Buttons binded to the Model... it looks like the default ContentPresenters that are part of either RibbonTabItem or RibbonTabControl are not doing what we need to to... this is where I'm currently stuck. I think I'm almost there though.

Do you or anybody else know what direction to take on this? It would be greatly appreciated, as this MVVM design would be much better suited for this variation of a Ribbon Library.

Cheers.

Jul 12, 2012 at 8:56 PM

Hi bl4kh4k,

I did not work for this specific project since the end of august in 2011. But I'm thinking of a further development of the application, so that my be interesting for me in the near future. Seems that you're almost reaching your target. Please let me know what you find out about that.

If you're interested you can browse the source code of the application that I and three other former students worked on on http://sourceforge.net/projects/mindtricks/ for getting some impressions.

 

 

Developer
Jul 16, 2012 at 10:25 PM
Edited Jul 16, 2012 at 10:28 PM

It would need massive changes to the Ribbon to enable full MVVM support, which i think, is what you want.

By the way, i think you destroy the automatic sizing/reducing by simply making RibbonTabItem a ContentControl, don't you?

I took a simpler approach at work and just made a factory which holds a reference to the ribbon and a list of RibbonTabViewModel.

The class layout looks something like this:

RibbonTabViewModel which has a list of RibbonGroupViewModel.

RibbonGroupViewModel which has a list of RibbonCommandViewModel.

RibbonCommandViewModel is subclassed by RibbonComboBoxCommandViewModel, RibbonCheckBoxCommandViewModel, etc.

 

The factory then listens for changes to the list of RibbonTabViewModels and creates the RibbonTabItems filled with the control contained in the RibbonTabViewModel. I don't listen for changes made to the list of RibbonGroupViewModel, because the Ribbon shouldn't change groups or controls on the fly (would confuse users i think).

Jul 17, 2012 at 1:11 PM

Hi batzen,

Thanks for getting back to me… I did not notice any issues with resizing when switching the RibbonTabItem to a ContentControl. I think I’m very close to getting it to work, as I’m sure theres probably a ContentPresenter somewhere in the xaml that just needs to bind properly to the DataContext to populate through my design.

However, I’d like to try your approach by doing it in c# instead, unless you can think of the ContentPresenter that may need update to support the design I’m going for. You wouldn’t happen to have a sample project that illustrates the ViewModel’s for the Ribbon controls… it would be very helpful at this stage as I have spent about a week now trying to revamp the xaml to achieve the design I’m going for.

Thanks again,

Cheers,

Marty

From: batzen [email removed]
Sent: July-16-12 6:06 PM
To: martin.vanputten@live.com
Subject: Re: FluentRibbon TabItem outsourcing [fluent:252579]

From: batzen

It would need massive changes to the Ribbon to enable full MVVM support, which i think, is what you want.

By the way, i think you destroy the automatic sizing/reducing by simply making RibbonTabItem a ContentControl, don't you?

I took a simpler approach at work and just made a factory which holds a reference to the ribbon and a list of RibbonTabViewModel.

The class layout looks something like this:

RibbonTabViewModel which has a list of RibbonGroupViewModel.

RibbonGroupViewModel which has a list of RibbonCommandViewModel.

RibbonCommandViewModel is subclassed by RibbonComboBoxCommandViewModel, RibbonCheckBoxCommandViewModel, etc.

The factory then listens for changes to the list of RibbonTabViewModels and creates the RibbonTabItems filled with the control contained in the RibbonTabViewModel. I don't listen for changes made to the list of RibbonGroupViewModel, because the Ribbon shouldn't change groups or controls on the fly (would confuse users i think).

Oct 11, 2012 at 9:00 AM
Edited Oct 11, 2012 at 9:00 AM

I've done editing single tabItem in design time. Actually the problem is that Tab's groupBoxes do not belong to tab-they belong to Ribbon.
To solve this problem I've added additional Grid to Template for RibbonTabItem:

  <ControlTemplate TargetType="{x:Type Fluent:RibbonTabItem}">
          <Grid x:Name="grid" Background="#00000000" Height="Auto" VerticalAlignment="Top" Margin="0,7,0,0">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="24"/>
                            <RowDefinition Height="Auto"/>
                        </Grid.RowDefinitions>
                        <Grid Name="PART_DesignerContainer" Grid.Row="1"/>
                        <Border x:Name="border3" Margin="2,0,0,1" BorderThickness="1,0" Grid.ColumnSpan="2">


I've also rewritten OnLoaded method of ribbon TabItem:

 private void OnLoaded(object sender, RoutedEventArgs e)
        {
            if (System.ComponentModel.DesignerProperties.GetIsInDesignMode(this) && TabControlParent == null)
            {
                var designerContainer = GetTemplateChild("PART_DesignerContainer") as Panel;
                designerContainer.Children.Add(this.GroupsContainer);
            }
            else
                AddLogicalChild(groupsContainer);
            this.SubscribeEvents();
        }

So it works) Took me half of the day.