-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Addition of MaxOpenBlades property on BladeView control #1049
Changes from all commits
f97f20e
d3cba99
a3ad6f6
ddba3bb
d10769a
59713c2
5a656a3
77893d4
81debe1
c468100
e8cb995
82c50a7
b721fd8
380993e
fbfb8d6
5920cb9
722fb12
ccec769
b351e4d
8d24e6a
36a5d78
a84abfb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// ****************************************************************** | ||
// Copyright (c) Microsoft. All rights reserved. | ||
// This code is licensed under the MIT License (MIT). | ||
// THE CODE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, | ||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | ||
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, | ||
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, | ||
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH | ||
// THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE. | ||
// ****************************************************************** | ||
|
||
namespace Microsoft.Toolkit.Uwp.UI.Controls | ||
{ | ||
/// <summary> | ||
/// Blade item mode | ||
/// </summary> | ||
public enum BladeItemMode | ||
{ | ||
/// <summary> | ||
/// Normal mode | ||
/// </summary> | ||
Normal, | ||
|
||
/// <summary> | ||
/// Small mode | ||
/// </summary> | ||
Small | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -80,6 +80,7 @@ protected override void PrepareContainerForItemOverride(DependencyObject element | |
} | ||
|
||
base.PrepareContainerForItemOverride(element, item); | ||
CycleBlades(); | ||
} | ||
|
||
/// <summary> | ||
|
@@ -108,6 +109,19 @@ private void CycleBlades() | |
ActiveBlades.Add(blade); | ||
} | ||
} | ||
|
||
// For now we skip this feature when blade mode is set to fullscreen | ||
if (AutoCollapseCountThreshold > 0 && BladeMode != BladeMode.Fullscreen && ActiveBlades.Any()) | ||
{ | ||
var openBlades = ActiveBlades.Where(item => item.TitleBarVisibility == Visibility.Visible).ToList(); | ||
if (openBlades.Count > AutoCollapseCountThreshold) | ||
{ | ||
for (int i = 0; i < openBlades.Count - 1; i++) | ||
{ | ||
openBlades[i].BladeItemMode = BladeItemMode.Small; | ||
} | ||
} | ||
} | ||
} | ||
|
||
private async void BladeOnVisibilityChanged(object sender, Visibility visibility) | ||
|
@@ -116,6 +130,11 @@ private async void BladeOnVisibilityChanged(object sender, Visibility visibility | |
|
||
if (visibility == Visibility.Visible) | ||
{ | ||
if (Items == null) | ||
{ | ||
return; | ||
} | ||
|
||
Items.Remove(blade); | ||
Items.Add(blade); | ||
BladeOpened?.Invoke(this, blade); | ||
|
@@ -133,6 +152,12 @@ await Dispatcher.RunAsync(CoreDispatcherPriority.Low, () => | |
|
||
BladeClosed?.Invoke(this, blade); | ||
ActiveBlades.Remove(blade); | ||
|
||
var lastBlade = ActiveBlades.LastOrDefault(); | ||
if (lastBlade != null && lastBlade.TitleBarVisibility == Visibility.Visible) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't check the titlebar visibility. This can be set to collapsed by the user but still want the last blade to be expanded There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same remark as above, I don't want to auto size pinned blades. |
||
{ | ||
lastBlade.BladeItemMode = BladeItemMode.Normal; | ||
} | ||
} | ||
|
||
private ScrollViewer GetScrollViewer() | ||
|
@@ -175,4 +200,4 @@ private void ItemsVectorChanged(IObservableVector<object> sender, IVectorChanged | |
} | ||
} | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should check the expand mode instead of the visibility of the title bar. This could be set by the user
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My understanding was that the TitleBarVisibility property was used to pin blades to the screen.
I want to filter the pinned once out, they are not touched by the auto resize mechanism.
@skendrot Is there another property that tells me this? I don't seem to find it...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right! Thanks for pointing that out