michael-hawker 2022-10-18 00:15:56 -07:00
Родитель 70f7ab8919
Коммит 60d61ad62a
7 изменённых файлов: 12 добавлений и 12 удалений

Просмотреть файл

@ -440,7 +440,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
var incc = (INotifyCollectionChanged)newValue;
_inccWeakEventListener = new WeakEventListener<RotatorTile, object, NotifyCollectionChangedEventArgs>(this)
{
OnEventAction = (instance, source, eventArgs) => instance.Incc_CollectionChanged(source, eventArgs),
OnEventAction = static (instance, source, eventArgs) => instance.Incc_CollectionChanged(source, eventArgs),
OnDetachAction = (listener) => incc.CollectionChanged -= listener.OnEvent
};
incc.CollectionChanged += _inccWeakEventListener.OnEvent;

Просмотреть файл

@ -62,7 +62,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
{
var weakPropertyChangedListener = new WeakEventListener<InterspersedObservableCollection, object, NotifyCollectionChangedEventArgs>(this)
{
OnEventAction = (instance, source, eventArgs) => instance.ItemsSource_CollectionChanged(source, eventArgs),
OnEventAction = static (instance, source, eventArgs) => instance.ItemsSource_CollectionChanged(source, eventArgs),
OnDetachAction = (weakEventListener) => notifier.CollectionChanged -= weakEventListener.OnEvent // Use Local Reference Only
};
notifier.CollectionChanged += weakPropertyChangedListener.OnEvent;

Просмотреть файл

@ -97,7 +97,7 @@ namespace Microsoft.Toolkit.Uwp.UI
new WeakEventListener<AdvancedCollectionView, object, NotifyCollectionChangedEventArgs>(this)
{
// Call the actual collection changed event
OnEventAction = (source, changed, arg3) => SourceNcc_CollectionChanged(source, arg3),
OnEventAction = static (instance, source, arg3) => instance.SourceNcc_CollectionChanged(source, arg3),
// The source doesn't exist anymore
OnDetachAction = (listener) => sourceNcc.CollectionChanged -= _sourceWeakEventListener.OnEvent

Просмотреть файл

@ -23,7 +23,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Triggers
var weakEvent =
new WeakEventListener<FullScreenModeStateTrigger, ApplicationView, object>(this)
{
OnEventAction = (instance, source, eventArgs) => instance.FullScreenModeTrigger_VisibleBoundsChanged(source, eventArgs),
OnEventAction = static (instance, source, eventArgs) => instance.FullScreenModeTrigger_VisibleBoundsChanged(source, eventArgs),
OnDetachAction = (weakEventListener) => ApplicationView.GetForCurrentView().VisibleBoundsChanged -= weakEventListener.OnEvent
};
ApplicationView.GetForCurrentView().VisibleBoundsChanged += weakEvent.OnEvent;

Просмотреть файл

@ -47,9 +47,9 @@ namespace Microsoft.Toolkit.Uwp.UI.Triggers
var valNotifyCollection = val as INotifyCollectionChanged;
if (valNotifyCollection != null)
{
var weakEvent = new WeakEventListener<INotifyCollectionChanged, object, NotifyCollectionChangedEventArgs>(valNotifyCollection)
var weakEvent = new WeakEventListener<IsNullOrEmptyStateTrigger, object, NotifyCollectionChangedEventArgs>(obj)
{
OnEventAction = (instance, source, args) => obj.SetActive(IsNullOrEmpty(instance)),
OnEventAction = static (instance, source, args) => instance.SetActive(IsNullOrEmpty(source)),
OnDetachAction = (weakEventListener) => valNotifyCollection.CollectionChanged -= weakEventListener.OnEvent
};
@ -61,9 +61,9 @@ namespace Microsoft.Toolkit.Uwp.UI.Triggers
var valObservableVector = val as IObservableVector<object>;
if (valObservableVector != null)
{
var weakEvent = new WeakEventListener<IObservableVector<object>, object, IVectorChangedEventArgs>(valObservableVector)
var weakEvent = new WeakEventListener<IsNullOrEmptyStateTrigger, object, IVectorChangedEventArgs>(obj)
{
OnEventAction = (instance, source, args) => obj.SetActive(IsNullOrEmpty(instance)),
OnEventAction = static (instance, source, args) => instance.SetActive(IsNullOrEmpty(source)),
OnDetachAction = (weakEventListener) => valObservableVector.VectorChanged -= weakEventListener.OnEvent
};
@ -75,9 +75,9 @@ namespace Microsoft.Toolkit.Uwp.UI.Triggers
var valObservableMap = val as IObservableMap<object, object>;
if (valObservableMap != null)
{
var weakEvent = new WeakEventListener<IObservableMap<object, object>, object, IMapChangedEventArgs<object>>(valObservableMap)
var weakEvent = new WeakEventListener<IsNullOrEmptyStateTrigger, object, IMapChangedEventArgs<object>>(obj)
{
OnEventAction = (instance, source, args) => obj.SetActive(IsNullOrEmpty(instance)),
OnEventAction = static (instance, source, args) => instance.SetActive(IsNullOrEmpty(source)),
OnDetachAction = (weakEventListener) => valObservableMap.MapChanged -= weakEventListener.OnEvent
};

Просмотреть файл

@ -25,7 +25,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Triggers
var weakEvent =
new WeakEventListener<NetworkConnectionStateTrigger, object>(this)
{
OnEventAction = (instance, source) => NetworkInformation_NetworkStatusChanged(source),
OnEventAction = static (instance, source) => instance.NetworkInformation_NetworkStatusChanged(source),
OnDetachAction = (weakEventListener) => NetworkInformation.NetworkStatusChanged -= weakEventListener.OnEvent
};
NetworkInformation.NetworkStatusChanged += weakEvent.OnEvent;

Просмотреть файл

@ -24,7 +24,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Triggers
var weakEvent =
new WeakEventListener<UserInteractionModeStateTrigger, object, WindowSizeChangedEventArgs>(this)
{
OnEventAction = (instance, source, eventArgs) => UserInteractionModeTrigger_SizeChanged(source, eventArgs),
OnEventAction = static (instance, source, eventArgs) => instance.UserInteractionModeTrigger_SizeChanged(source, eventArgs),
OnDetachAction = (weakEventListener) => Window.Current.SizeChanged -= weakEventListener.OnEvent
};
Window.Current.SizeChanged += weakEvent.OnEvent;