Browse Source
Merge pull request #3750 from AvaloniaUI/fixes/2755-brush-opacity
Invalidate brush when Opacity changes.
pull/3763/head
Nikita Tsukanov
6 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
17 additions and
0 deletions
-
src/Avalonia.Visuals/Media/Brush.cs
-
tests/Avalonia.Visuals.UnitTests/Media/BrushTests.cs
|
|
|
@ -19,6 +19,11 @@ namespace Avalonia.Media |
|
|
|
/// <inheritdoc/>
|
|
|
|
public event EventHandler Invalidated; |
|
|
|
|
|
|
|
static Brush() |
|
|
|
{ |
|
|
|
AffectsRender<Brush>(OpacityProperty); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Gets or sets the opacity of the brush.
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
@ -77,5 +77,17 @@ namespace Avalonia.Visuals.UnitTests.Media |
|
|
|
{ |
|
|
|
Assert.Throws<FormatException>(() => Brush.Parse("#ff808g80")); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public void Changing_Opacity_Raises_Invalidated() |
|
|
|
{ |
|
|
|
var target = new SolidColorBrush(); |
|
|
|
var raised = false; |
|
|
|
|
|
|
|
target.Invalidated += (s, e) => raised = true; |
|
|
|
target.Opacity = 0.5; |
|
|
|
|
|
|
|
Assert.True(raised); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|