Browse Source
Merge pull request #10171 from workgroupengineering/features/Samples/Controls/HanburgerMenu/Auto-Close
feat(HamburgerMenu): Auto close on SelectedItem Changed when HamburgerMenu is display as Overlay
pull/10169/head
Max Katz
3 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
12 additions and
4 deletions
-
samples/ControlCatalog/MainView.xaml
-
samples/SampleControls/HamburgerMenu/HamburgerMenu.cs
|
|
|
@ -14,8 +14,8 @@ |
|
|
|
<Setter Property="HorizontalAlignment" Value="Left" /> |
|
|
|
</Style> |
|
|
|
</Grid.Styles> |
|
|
|
<controls:HamburgerMenu Name="Sidebar"> |
|
|
|
<TabItem Header="Composition"> |
|
|
|
<controls:HamburgerMenu Name="Sidebar"> |
|
|
|
<TabItem Header="Composition"> |
|
|
|
<pages:CompositionPage/> |
|
|
|
</TabItem> |
|
|
|
<TabItem Header="Acrylic"> |
|
|
|
|
|
|
|
@ -52,6 +52,14 @@ namespace ControlSamples |
|
|
|
var (oldBounds, newBounds) = change.GetOldAndNewValue<Rect>(); |
|
|
|
EnsureSplitViewMode(oldBounds, newBounds); |
|
|
|
} |
|
|
|
|
|
|
|
if (change.Property == SelectedItemProperty) |
|
|
|
{ |
|
|
|
if (_splitView is not null && _splitView.DisplayMode == SplitViewDisplayMode.Overlay) |
|
|
|
{ |
|
|
|
_splitView.SetValue(SplitView.IsPaneOpenProperty, false, Avalonia.Data.BindingPriority.Animation); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private void EnsureSplitViewMode(Rect oldBounds, Rect newBounds) |
|
|
|
@ -60,12 +68,12 @@ namespace ControlSamples |
|
|
|
{ |
|
|
|
var threshold = ExpandedModeThresholdWidth; |
|
|
|
|
|
|
|
if (newBounds.Width >= threshold && oldBounds.Width < threshold) |
|
|
|
if (newBounds.Width >= threshold) |
|
|
|
{ |
|
|
|
_splitView.DisplayMode = SplitViewDisplayMode.Inline; |
|
|
|
_splitView.IsPaneOpen = true; |
|
|
|
} |
|
|
|
else if (newBounds.Width < threshold && oldBounds.Width >= threshold) |
|
|
|
else if (newBounds.Width < threshold) |
|
|
|
{ |
|
|
|
_splitView.DisplayMode = SplitViewDisplayMode.Overlay; |
|
|
|
_splitView.IsPaneOpen = false; |
|
|
|
|