RibbonGroupBox.ItemsSource and window maximized state issues

Apr 6, 2010 at 5:09 AM

Hi,

Fluent Ribbon is a great control and I'm using it with pleasure.

Anyway, I would like you to notice a few things that seem not working:

  • If I use the RibbonGroupBox.ItemsSource to generate the buttons in a typical MVVM application, anything appears
  • The WindowState Maximized doesn't really work, it just gets the dimensions of the screen but it is not in a maximized state

Thank you and good work

Francesco

Coordinator
Apr 6, 2010 at 5:45 AM

Thank you, Francesco.

I have just tried the code below, and it works properly.

var src = new Button[]
              {
                  new Button(){Text="ll1",Size=RibbonControlSize.Middle}, 
                  new Button(){Text="l21",Size=RibbonControlSize.Middle}, 
                  new Button(){Text="l31",Size=RibbonControlSize.Middle}, 
                  new Button(){Text="l41"}, 
                  new Button(){Text="l51"}, 
              };
ribbonGroupBox.ItemsSource = src;

WindowState Maximized will be fixed in v1.1

Serg

Apr 6, 2010 at 8:55 AM
Edited Apr 6, 2010 at 9:05 AM

Hi Serg,

 

thank you for your answer. I'm trying to do it in a MVVM way, so I don't a source which contains buttons but "CommandViewModel"; the code is similar to this:

 

<fluent:RibbonTabItem DataContext="{Binding Path=Toolbox}" Group="{Binding ElementName=ribbonDiagramGroup}" Header="{Binding Path=Header}">
                <fluent:RibbonGroupBox Header="New item">
                    <fluent:InRibbonGallery ItemsSource="{Binding Path=Items}">
                        <fluent:InRibbonGallery.ItemTemplate>
                            <DataTemplate>
                                <fluent:Button Text="{Binding Mode=OneWay, Path=Header}">
                                    <i:Interaction.Triggers>
                                        <i:EventTrigger EventName="PreviewMouseLeftButtonDown">
                                            <cmd:EventToCommand Command="{Binding Path=PreviewMouseLeftButtonDownCommand}" PassEventArgsToCommand="True"/>
                                        </i:EventTrigger>
                                        <i:EventTrigger EventName="MouseMove">
                                            <cmd:EventToCommand Command="{Binding Path=MouseMoveCommand}" PassEventArgsToCommand="True"/>
                                        </i:EventTrigger>
                                    </i:Interaction.Triggers>
                                </fluent:Button>
                            </DataTemplate>
                        </fluent:InRibbonGallery.ItemTemplate>
                    </fluent:InRibbonGallery>
                </fluent:RibbonGroupBox>
            </fluent:RibbonTabItem>

 

The code above doesn't work. Toolbox is a custom ToolboxViewModel class and Items is of type ObservableCollection<ToolboxItemViewModel>.

I hope this helps you reproducing the problem, otherwise I will provide you more details.

 

Update: this example works if I change the binding path of the InRibbonGallery from Items to Toolbox.Items, but I can't understand why the DataContext is not inherited from the RibbonTabItem.

 

Thank you,

Francesco

Apr 15, 2010 at 6:28 AM

I realized that the problem raises up when the datacontext is changed during the lifetime of the application.

I will try to give you a simplified example reproducing the issue.