Browse Source

Implement SetItems method in ResourceDictionary (#18354)

* Implement AddOrUpdateRange method in ResourceDictionary

* Change to SetItems method nam, remove flag

---------

Co-authored-by: Julien Lebosquain <julien@lebosquain.net>
pull/18412/head
StefanKoell 2 years ago
committed by GitHub
parent
commit
ce72eced6b
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 16
      src/Avalonia.Base/Controls/ResourceDictionary.cs

16
src/Avalonia.Base/Controls/ResourceDictionary.cs

@ -40,7 +40,8 @@ namespace Avalonia.Controls
set
{
Inner[key] = value;
Owner?.NotifyHostedResourcesChanged(ResourcesChangedEventArgs.Empty);
Owner?.NotifyHostedResourcesChanged(ResourcesChangedEventArgs.Empty);
}
}
@ -150,6 +151,19 @@ namespace Avalonia.Controls
public void AddNotSharedDeferred(object key, IDeferredContent deferredContent)
=> Add(key, new NotSharedDeferredItem(deferredContent));
public void SetItems(IEnumerable<KeyValuePair<object, object?>> values)
{
try
{
foreach (var value in values)
Inner[value.Key] = value.Value;
}
finally
{
Owner?.NotifyHostedResourcesChanged(ResourcesChangedEventArgs.Empty);
}
}
public void Clear()
{
if (_inner?.Count > 0)

Loading…
Cancel
Save