-
Notifications
You must be signed in to change notification settings - Fork 742
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(ItemsControl): [Android] Adjust collection update reset for ComboBox
- Loading branch information
1 parent
31c5cc9
commit 8581995
Showing
4 changed files
with
165 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Uno.UI.Tests.Helpers | ||
{ | ||
internal class ObservableCollectionEx<TType> : System.Collections.ObjectModel.ObservableCollection<TType> | ||
{ | ||
private int _batchUpdateCount; | ||
|
||
public IDisposable BatchUpdate() | ||
{ | ||
++_batchUpdateCount; | ||
|
||
return Uno.Disposables.Disposable.Create(Release); | ||
|
||
void Release() | ||
{ | ||
if (--_batchUpdateCount <= 0) | ||
{ | ||
OnCollectionChanged(new System.Collections.Specialized.NotifyCollectionChangedEventArgs(System.Collections.Specialized.NotifyCollectionChangedAction.Reset)); | ||
} | ||
} | ||
} | ||
|
||
protected override void OnCollectionChanged(System.Collections.Specialized.NotifyCollectionChangedEventArgs e) | ||
{ | ||
if (_batchUpdateCount > 0) | ||
{ | ||
return; | ||
} | ||
|
||
base.OnCollectionChanged(e); | ||
} | ||
|
||
public void Append(TType item) => Add(item); | ||
|
||
public TType GetAt(int index) => this[index]; | ||
} | ||
} |
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