forked from lepoco/wpfui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'development' into development
- Loading branch information
Showing
10 changed files
with
153 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -450,6 +450,53 @@ public Thickness FrameMargin | |
set => SetValue(FrameMarginProperty, value); | ||
} | ||
|
||
private void OnMenuItemsSource_CollectionChanged( | ||
object? sender, | ||
IList collection, | ||
NotifyCollectionChangedEventArgs e | ||
) | ||
{ | ||
if (ReferenceEquals(sender, collection)) | ||
{ | ||
return; | ||
} | ||
|
||
switch (e.Action) | ||
{ | ||
case NotifyCollectionChangedAction.Add: | ||
foreach (var item in e.NewItems) | ||
{ | ||
collection.Add(item); | ||
} | ||
Check warning on line 470 in src/Wpf.Ui/Controls/NavigationView/NavigationView.Properties.cs GitHub Actions / build
|
||
break; | ||
|
||
case NotifyCollectionChangedAction.Remove: | ||
foreach (var item in e.OldItems) | ||
{ | ||
if (!e.NewItems.Contains(item)) | ||
{ | ||
collection.Remove(item); | ||
} | ||
} | ||
Check warning on line 480 in src/Wpf.Ui/Controls/NavigationView/NavigationView.Properties.cs GitHub Actions / build
|
||
break; | ||
|
||
case NotifyCollectionChangedAction.Move: | ||
var moveItem = MenuItems[e.OldStartingIndex]; | ||
collection.RemoveAt(e.OldStartingIndex); | ||
collection.Insert(e.NewStartingIndex, moveItem); | ||
break; | ||
|
||
case NotifyCollectionChangedAction.Replace: | ||
collection.RemoveAt(e.OldStartingIndex); | ||
collection.Insert(e.OldStartingIndex, e.NewItems[0]); | ||
break; | ||
|
||
case NotifyCollectionChangedAction.Reset: | ||
collection.Clear(); | ||
break; | ||
} | ||
} | ||
|
||
private void OnMenuItems_CollectionChanged(object? sender, NotifyCollectionChangedEventArgs e) | ||
{ | ||
if (e.NewItems is null) | ||
|
@@ -481,6 +528,12 @@ private static void OnMenuItemsSourceChanged(DependencyObject? d, DependencyProp | |
{ | ||
navigationView.MenuItems.Add(e.NewValue); | ||
} | ||
|
||
if (e.NewValue is INotifyCollectionChanged oc) | ||
{ | ||
oc.CollectionChanged += (s, e) => | ||
navigationView.OnMenuItemsSource_CollectionChanged(oc, navigationView.MenuItems, e); | ||
} | ||
} | ||
|
||
private void OnFooterMenuItems_CollectionChanged(object? sender, NotifyCollectionChangedEventArgs e) | ||
|
@@ -517,6 +570,12 @@ DependencyPropertyChangedEventArgs e | |
{ | ||
navigationView.FooterMenuItems.Add(e.NewValue); | ||
} | ||
|
||
if (e.NewValue is INotifyCollectionChanged oc) | ||
{ | ||
oc.CollectionChanged += (s, e) => | ||
navigationView.OnMenuItemsSource_CollectionChanged(oc, navigationView.FooterMenuItems, e); | ||
} | ||
} | ||
|
||
private static void OnPaneDisplayModeChanged(DependencyObject? d, DependencyPropertyChangedEventArgs e) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters