Skip to content

Commit

Permalink
Fixes #419 by using TabControlParent instead of Parent
Browse files Browse the repository at this point in the history
  • Loading branch information
batzen committed Apr 1, 2017
1 parent 3423929 commit db1bd77
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

- ### Bug fixes
- [#405](../../issues/405) - InRibbonGallery when loaded, mouse wheel up or down cause crash. (thanks @Yumeryu)
- [#419](../../issues/419) - BackstageTabItem Is Never Deselected if BackstageTabControl is not Logical Parent

## 5.0.1
- ### Bug fixes
Expand Down
10 changes: 4 additions & 6 deletions Fluent.Ribbon/Controls/BackstageTabItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,16 +134,14 @@ private static void OnIsSelectedChanged(DependencyObject d, DependencyPropertyCh
var container = (BackstageTabItem)d;
var newValue = (bool)e.NewValue;

var backstageTabControl = container.Parent as BackstageTabControl;

if (newValue)
{
if (backstageTabControl != null
&& ReferenceEquals(backstageTabControl.ItemContainerGenerator.ContainerFromItem(backstageTabControl.SelectedItem), container) == false)
if (container.TabControlParent != null
&& ReferenceEquals(container.TabControlParent.ItemContainerGenerator.ContainerFromItem(container.TabControlParent.SelectedItem), container) == false)
{
UnselectSelectedItem(backstageTabControl);
UnselectSelectedItem(container.TabControlParent);

backstageTabControl.SelectedItem = backstageTabControl.ItemContainerGenerator.ItemFromContainer(container);
container.TabControlParent.SelectedItem = container.TabControlParent.ItemContainerGenerator.ItemFromContainer(container);
}

container.OnSelected(new RoutedEventArgs(Selector.SelectedEvent, container));
Expand Down

0 comments on commit db1bd77

Please sign in to comment.