Browse Source
Merge pull request #2740 from AvaloniaUI/fixes/2584-styles-findresource
Fix searching for merged resources in Styles
pull/2748/head
Nikita Tsukanov
7 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
25 additions and
1 deletions
-
src/Avalonia.Styling/Styling/Styles.cs
-
tests/Avalonia.Styling.UnitTests/StylesTests.cs
|
|
|
@ -180,7 +180,7 @@ namespace Avalonia.Styling |
|
|
|
/// <inheritdoc/>
|
|
|
|
public bool TryGetResource(object key, out object value) |
|
|
|
{ |
|
|
|
if (_resources != null && _resources.TryGetValue(key, out value)) |
|
|
|
if (_resources != null && _resources.TryGetResource(key, out value)) |
|
|
|
{ |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
@ -2,6 +2,7 @@ |
|
|
|
// Licensed under the MIT license. See licence.md file in the project root for full license information.
|
|
|
|
|
|
|
|
using System; |
|
|
|
using Avalonia.Controls; |
|
|
|
using Xunit; |
|
|
|
|
|
|
|
namespace Avalonia.Styling.UnitTests |
|
|
|
@ -111,5 +112,28 @@ namespace Avalonia.Styling.UnitTests |
|
|
|
|
|
|
|
Assert.False(raised); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[Fact] |
|
|
|
public void Finds_Resource_In_Merged_Dictionary() |
|
|
|
{ |
|
|
|
var target = new Styles |
|
|
|
{ |
|
|
|
Resources = new ResourceDictionary |
|
|
|
{ |
|
|
|
MergedDictionaries = |
|
|
|
{ |
|
|
|
new ResourceDictionary |
|
|
|
{ |
|
|
|
{ "foo", "bar" }, |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
var result = target.FindResource("foo"); |
|
|
|
|
|
|
|
Assert.Equal("bar", result); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|