Fluent.InRibbonGallery.OnFilterChanged C# (CSharp) Method

OnFilterChanged() static private method

static private OnFilterChanged ( DependencyObject d, System.Windows.DependencyPropertyChangedEventArgs e ) : void
d System.Windows.DependencyObject
e System.Windows.DependencyPropertyChangedEventArgs
return void
        static void OnFilterChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            InRibbonGallery gallery = (InRibbonGallery)d;
            GalleryGroupFilter oldFilter = e.OldValue as GalleryGroupFilter;
            if (oldFilter != null)
            {
                System.Windows.Controls.MenuItem menuItem = gallery.GetFilterMenuItem(oldFilter);
                if (menuItem != null) menuItem.IsChecked = false;
            }
            GalleryGroupFilter filter = e.NewValue as GalleryGroupFilter;
            if (filter != null)
            {
                gallery.SelectedFilterTitle = filter.Title;
                gallery.SelectedFilterGroups = filter.Groups;
                System.Windows.Controls.MenuItem menuItem = gallery.GetFilterMenuItem(filter);
                if (menuItem != null) menuItem.IsChecked = true;
            }
            else
            {
                gallery.SelectedFilterTitle = "";
                gallery.SelectedFilterGroups = null;
            }
            gallery.UpdateLayout();
        }