RadRibbonGroup - visibility bound to data object not working properly.

2 posts, 0 answers
  1. Rob
    Rob avatar
    238 posts
    Member since:
    Jan 2009

    Posted 23 Nov 2012 Link to this post

    Hello,

    I have discovered a problem when binding the visibiltiy of RadRibbonGroups to a data object.  Please see the sample project below.

    You will see that several RadRibbonGroups are bound to the "MyDataObject.IsNew" property and several others are bound to the "CheckBox.IsChecked" property.  Check the box and see what happens.  You'll notice that only some of the groups are displayed...

    Ribbon1 will show nothing (the group is bound to "MyDataObject.IsNew").
    Ribbon2 will show a group (bound to "CheckBox.IsChecked").
    Ribbon3 will show both groups (one bound to "CheckBox.IsChecked" and one to "MyDataObject.IsNew").

    After the checkbox is checked, and the groups have not shown up... grab your browser and resize it slightly.  I think an UpdateLayout event occurs and fixes the display of Ribbon1.  My guess is that an updatelayout event occurs on the checkbox bound groups which is why Ribbon2 and Ribbon3 worked initially.

    <Grid x:Name="LayoutRoot" Background="White">
      <Grid.RowDefinitions>
        <RowDefinition Height="Auto" />
        <RowDefinition Height="1*" />
        <RowDefinition Height="1*" />
      </Grid.RowDefinitions>
      <Grid.ColumnDefinitions>
        <ColumnDefinition Width="1*"/>
        <ColumnDefinition Width="1*"/>
      </Grid.ColumnDefinitions>
      <CheckBox x:Name="cb" Grid.ColumnSpan="2" IsChecked="{Binding IsNew, Mode=TwoWay}" Content="Is New" Margin="0,20,0,20" />
      <telerik:RadRibbonView Grid.Row="1" Grid.Column="0">
        <telerik:RadRibbonTab Header="Ribbon1">
          <telerik:RadRibbonGroup Visibility="{Binding IsNew, Converter={StaticResource BoolToVis}, Mode=TwoWay}" Header="IsNew"/>
        </telerik:RadRibbonTab>
      </telerik:RadRibbonView>
      <telerik:RadRibbonView Grid.Row="1" Grid.Column="1">
        <telerik:RadRibbonTab Header="Ribbon2">
          <telerik:RadRibbonGroup Visibility="{Binding IsChecked, ElementName=cb, Converter={StaticResource BoolToVis}, Mode=TwoWay}" Header="IsChecked"/>
        </telerik:RadRibbonTab>
      </telerik:RadRibbonView>
      <telerik:RadRibbonView Grid.Row="2" Grid.ColumnSpan="2">
        <telerik:RadRibbonTab Header="Ribbon3">
          <telerik:RadRibbonGroup Visibility="{Binding IsNew, Converter={StaticResource BoolToVis}, Mode=TwoWay}" Header="IsNew"/>
          <telerik:RadRibbonGroup Visibility="{Binding IsChecked, ElementName=cb, Converter={StaticResource BoolToVis}, Mode=TwoWay}" Header="IsChecked"/>
        </telerik:RadRibbonTab>
      </telerik:RadRibbonView>
    </Grid>


    using System.ComponentModel;
    using System.Windows;
    using System.Windows.Controls;
     
    namespace SilverlightApplication30
    {
      public partial class MainPage : UserControl
      {
        MyDataObject mdo = new MyDataObject();
        public MainPage()
        {
          InitializeComponent();
          this.Loaded += MainPage_Loaded;
        }
        void MainPage_Loaded(object sender, RoutedEventArgs e)
        {
          this.DataContext = mdo;
        }
      }
         
      public class MyDataObject : INotifyPropertyChanged
      {
        private bool _IsNew = false;
        public bool IsNew
        {
          get
          {
            return this._IsNew;
          }
          set
          {
            if (this._IsNew == value)
              return;
            this._IsNew = value;
            RaisePropertyChanged("IsNew");
          }
        }
        public event PropertyChangedEventHandler PropertyChanged;
        protected void RaisePropertyChanged(string propertyName)
        {
          PropertyChangedEventHandler propertyChanged = PropertyChanged; 
          if ((propertyChanged != null))
          {
            propertyChanged(this, new PropertyChangedEventArgs(propertyName));
          }
        }
      }
    }





  2. Stefan
    Admin
    Stefan avatar
    89 posts

    Posted 28 Nov 2012 Link to this post

    Hello Rob,

    Thank you for your report. This is a known bug and it is already fixed. The fix is available in our latest internal build. Also it would be included in our incoming Service Pack, which will be release until the end of the week.

    Please give those version a try and let us know if the bug still presents.

    Regards,
    Stefan
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. DevCraft banner
Back to Top