Binding Breaks on resize RibbonGroup (micorsoft ribbon) for ComboBox


  • Hi

    I am have desktop application with Microsoft Ribbon , in this application we have placed Ribbon Group inside the ribbon Tab

     This RibbonGroup Contains a Combobox with its Binding of items sources to the ViewModel

     But the problem is that when i resize the main window so that Ribbon group becomes small in sized (say Collapsed) and after resizing the main window the binding of combobox is broken and combobox is  emply in elements

    can some body help in to regain the binding of combobox in ribbonGroup after it is collapsed.




    Friday, October 29, 2010 8:06 AM

All replies

  • Hi Amit Kamal Sharma,

    I followed your steps but cannot reproduce this issue on my side. The binding on the ComboBox works fine before and after it is collaspsed.

    It will be helpful if you can provide a sample and detailed steps to reproduce this issue.

    Best regards,


    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
    Tuesday, November 02, 2010 8:15 AM
  • Hi,

    I am also facing the same issue. When i resize window to its minimum (by dragging it) and then maxamize it, combobox values getting cleared.


    Thursday, December 02, 2010 8:02 AM
  • Hi,

    I have the same problem with Microsoft Ribbon. This is my sample:

    <Window x:Class="WpfApplication.MainWindow"
        Title="MainWindow" Height="350" Width="525" Name="_MainWindow" 
      <my:Ribbon Name="ribbon1">
        <my:RibbonTab Header="Tab" Name="ribbonTab1">
          <my:RibbonGroup Header="Group" Name="ribbonGroup1">
            <Label  Content="{Binding DataText}"></Label>
            <Button Width="40" Height="20" Click="Button_Click"></Button>
          <my:RibbonGroup Header="Group">
            <Label Content="{Binding DataText}"></Label>
            <Button Grid.Column="0" Grid.Row="1" Width="40" Height="20" Click="Button_Click"></Button>


    and code:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Data;
    using System.Windows.Documents;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Imaging;
    using System.Windows.Navigation;
    using System.Windows.Shapes;
    using System.ComponentModel;
    namespace WpfApplication
      /// <summary>
      /// Interaction logic for MainWindow.xaml
      /// </summary>
      public partial class MainWindow : Window
        Data _data;
        public MainWindow()
          _data = new Data();
          _MainWindow.DataContext = _data;
        private void Button_Click(object sender, RoutedEventArgs e)
          _data.DataText = "Test";
      public class Data : INotifyPropertyChanged 
        string _dataText;
        public string DataText 
          get { return _dataText; }
          set { _dataText = value; if (PropertyChanged != null) { PropertyChanged(this, new PropertyChangedEventArgs("DataText")); } }
        public event PropertyChangedEventHandler PropertyChanged;

    You need next steps to reproduce a problem:

    1. start application

    2. click a button in ribbon group. The string "Test" will be added to labels.

    3. Resize main window for collapse second ribbon group

    4. Return to previous main window size - the label content in second ribbon group will be destroid.

    I found one solution: You can inherite the RibbonGroup and in overrided method "OnPropertyChanged" reset RibbonGroup DataContext (save it in local variable, set DataContext  to null, restore DataContext from variable) for  force the reset binding. But may be there is more simple solution?

    Thursday, December 16, 2010 8:02 AM
  • B"H


    Has anyone found a solution to this?

    It is totaly unusable in the current state. If a group ever gets collapsed then all of its children loose their databinding.

    Friday, May 27, 2011 7:52 PM
  • hmmmmm... Sounds like the datacontext is changing or being set to null... 

    Do you see any path binding errors in VS output window when this happens?

    You could try this, you can disable just my code in debug window and see if any mal work is being seen over on Windows side via com interop or something similar. 

    Friday, May 27, 2011 8:03 PM
  • The same thing is happening to my application.  Using Snoop, I just verified that the DataContext of the affected control is in fact being set to null when the window is resized to the point where the RibbonGroup that contains the control gets collapsed or minimized or whatever it's called when it turns into a little blank square.

    There are no error messages in the VS output window when this happens, which is why I had to use Snoop to confirm it.

    Hope someone comes up with a solution or workaround for this.  I agree with Moshe, above, that this is a fatal flaw in the ribbon control.  Now if I was more than four weeks to my release deadline...


    Monday, August 15, 2011 9:13 PM
  • From further investigation, the binding isn't getting broken, it just doesn't know when to refresh.  If you callapse the tab bar completely then reopen it the binding is back to life.  Also, when you collapse the Tab Bar you'll notice the getter on the property is hit. 
    Michael Stacie
    Monday, August 15, 2011 9:55 PM
  • I got it to work by changing the Binding a little:

    <Window x:Class="WpfApplication1.MainWindow"
            Title="MainWindow" Height="350" Width="525" Name="_MainWindow" 
        <my:Ribbon Name="ribbon1">
            <my:RibbonTab Header="Tab" Name="ribbonTab1">
                <my:RibbonGroup Header="Group" Name="ribbonGroup1">
                    <Label  Content="{Binding DataText}"></Label>
                    <Button Width="40" Height="20" Click="Button_Click"></Button>
                <my:RibbonGroup Header="Group">
                    <Label Content="{Binding DataContext.DataText, ElementName=_MainWindow}"></Label>
                    <Button Grid.Column="0" Grid.Row="1" Width="40" Height="20" Click="Button_Click"></Button>

    Michael Stacie
    Monday, August 15, 2011 10:14 PM
  • Ok so it was related to a binding error.  In this case no ref. to ElementName was there originally. Thanks for posting solution.

    Tuesday, August 16, 2011 2:03 AM
  • I used Ashalnov's solution to get the ribbon groups restore their bindings when collaping and expanding. Thanks a lot for that suggestions, as this problem was worrying me a lot. Effectively, I edited the RibbonControlsLibrary.dll source code adding the folowing code to RibbonGroup.cs:

            protected override void OnPropertyChanged(DependencyPropertyChangedEventArgs e)

                // Force the bindings to be restored after the ribbon group collapsed or expanded to a menu button.
                // This is a work-around for the problem described on these web sites:

                if (e.Property == RibbonGroup.IsCollapsedProperty)
                    object objDataContext = this.DataContext;
                    this.DataContext = null;
                    this.DataContext = objDataContext;

    This is not the first change I was forced to make to the source code and there are other issues I haven't been able to solve yet. I wonder whether there will ever be a new release of the library. The ribbon is very nice, but buggy.


    Rutger Koperdraad.

    Friday, March 16, 2012 4:28 PM
  • Ok found an easier issue. Added it to my blog

    But I am just setting the data context on the combo box that is loosing data context set from the page level. This solved my problem very simply.  Without changing any code, just added data context to the combo box inside my ribbon

    DataContext="{Binding ViewModel, Source={StaticResource Locator}}"

    Got A Byte

    • Proposed as answer by Byboth Tuesday, February 05, 2013 3:13 PM
    Tuesday, February 05, 2013 3:13 PM