Skip to content

Commit

Permalink
Fixing selection issues for ribbon tabs
Browse files Browse the repository at this point in the history
  • Loading branch information
batzen committed Mar 31, 2018
1 parent 95f289a commit c1220c8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 14 deletions.
14 changes: 4 additions & 10 deletions Fluent.Ribbon/Controls/RibbonTabItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -204,13 +204,7 @@ public bool IsSelected
/// <summary>
/// Gets ribbon tab control parent
/// </summary>
internal RibbonTabControl TabControlParent
{
get
{
return ItemsControl.ItemsControlFromItemContainer(this) as RibbonTabControl;
}
}
internal RibbonTabControl TabControlParent => UIHelper.GetParent<RibbonTabControl>(this);

/// <summary>
/// Gets or sets indent
Expand Down Expand Up @@ -756,7 +750,7 @@ protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e)
{
var newItem = this.TabControlParent.ItemContainerGenerator.ItemFromContainer(this);

if (ReferenceEquals(this.TabControlParent.SelectedTabItem, newItem))
if (ReferenceEquals(this.TabControlParent.SelectedItem, newItem))
{
this.TabControlParent.IsDropDownOpen = !this.TabControlParent.IsDropDownOpen;
}
Expand Down Expand Up @@ -790,8 +784,8 @@ private static void OnIsSelectedChanged(DependencyObject d, DependencyPropertyCh
var newValue = (bool)e.NewValue;
if (newValue)
{
if (container.TabControlParent?.SelectedItem is RibbonTabItem
&& ReferenceEquals(container.TabControlParent.SelectedItem, container) == false)
if (container.TabControlParent != null
&& ReferenceEquals(container.TabControlParent.SelectedTabItem, container) == false)
{
((RibbonTabItem)container.TabControlParent.SelectedItem).IsSelected = false;
}
Expand Down
6 changes: 2 additions & 4 deletions Fluent.Ribbon/Controls/RibbonTitleBar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ namespace Fluent
using System.Windows.Media;
using Fluent.Extensions;
using Fluent.Helpers;
using Fluent.Internal;
using Fluent.Internal.KnownBoxes;
using WindowChrome = ControlzEx.Windows.Shell.WindowChrome;

Expand Down Expand Up @@ -309,10 +310,7 @@ private void Update(Size constraint)
{
var firstVisibleItem = visibleGroups.First().FirstVisibleItem;

if (firstVisibleItem?.Parent != null)
{
canRibbonTabControlScroll = ((RibbonTabControl)firstVisibleItem.Parent).CanScroll;
}
canRibbonTabControlScroll = UIHelper.GetParent<RibbonTabControl>(firstVisibleItem)?.CanScroll == true;
}

if (this.IsCollapsed)
Expand Down

0 comments on commit c1220c8

Please sign in to comment.