Skip to content

Commit

Permalink
Fix issue where SplitView with IsPaneOpen set to False and DisplayMod…
Browse files Browse the repository at this point in the history
…e set to CompactInline glitching out (#67)
  • Loading branch information
Kinnara committed Apr 19, 2020
1 parent 28e3146 commit 2f4b9df
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
18 changes: 13 additions & 5 deletions ModernWpf.Controls/SplitView/SplitView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using System.Windows.Input;
using System.Windows.Markup;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Threading;
using ModernWpf.Controls.Primitives;

namespace ModernWpf.Controls
Expand Down Expand Up @@ -41,6 +41,12 @@ private bool IsLightDismissible

public override void OnApplyTemplate()
{
if (_displayModeStates != null)
{
_displayModeStates.CurrentStateChanging -= OnDisplayModeStatesCurrentStateChanging;
_displayModeStates.CurrentStateChanged -= OnDisplayModeStatesCurrentStateChanged;
}

base.OnApplyTemplate();

_templateRoot = this.GetTemplateRoot();
Expand Down Expand Up @@ -174,7 +180,7 @@ private void UpdateTemplateSettings()
templateSettings.OpenPaneLength = openPaneLength;
templateSettings.OpenPaneLengthMinusCompactLength = openPaneLengthMinusCompactLength;

RefreshDisplayModeState();
ReapplyDisplayModeState();
}

private void UpdatePaneClipRectangle()
Expand Down Expand Up @@ -298,7 +304,7 @@ private void UpdateVisualState(bool useTransitions = true)
UpdateOverlayVisibilityState(useTransitions);
}

private void RefreshDisplayModeState()
private void ReapplyDisplayModeState()
{
if (!_isDisplayModeStateChanging)
{
Expand All @@ -307,8 +313,10 @@ private void RefreshDisplayModeState()
{
if (!storyboard.CanFreeze)
{
storyboard.Remove(_templateRoot);
storyboard.Begin(_templateRoot, HandoffBehavior.SnapshotAndReplace, true);
// Wait for data binding to update the storyboard
Dispatcher.Invoke(() => { }, DispatcherPriority.DataBind);

storyboard.Begin(_templateRoot, true);
}
}
}
Expand Down
1 change: 0 additions & 1 deletion ModernWpf.Controls/SplitView/SplitView.properties.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ private static void OnCompactPaneLengthPropertyChanged(DependencyObject sender,
private void OnCompactPaneLengthPropertyChanged(DependencyPropertyChangedEventArgs args)
{
UpdateTemplateSettings();
UpdateDisplayModeState();
}

#endregion
Expand Down

0 comments on commit 2f4b9df

Please sign in to comment.