Skip to content

Commit 3ec0672

Browse files
committed
code_style: use DirectProperty for CopyText in CopyButton
1 parent 5f464fb commit 3ec0672

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

‎src/Views/CopyButton.cs‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,16 @@ public class CopyButton : Button
1313
{
1414
protected override Type StyleKeyOverride => typeof(Button);
1515

16-
public static readonly StyledProperty<string> CopyTextProperty =
17-
AvaloniaProperty.Register<CopyButton, string>(nameof(CopyText), string.Empty);
16+
public static readonly DirectProperty<CopyButton, string> CopyTextProperty =
17+
AvaloniaProperty.RegisterDirect<CopyButton, string>(
18+
nameof(CopyText),
19+
static o => o.CopyText,
20+
static (o, v) => o.CopyText = v);
1821

1922
public string CopyText
2023
{
21-
get => GetValue(CopyTextProperty);
22-
set => SetValue(CopyTextProperty, value);
24+
get => _copyText;
25+
set => SetAndRaise(CopyTextProperty, ref _copyText, value);
2326
}
2427

2528
public static readonly DirectProperty<CopyButton, bool> IsCopiedProperty =
@@ -115,6 +118,7 @@ protected override async void OnClick()
115118

116119
private readonly Path _copyIcon;
117120
private readonly Path _checkIcon;
121+
private string _copyText = string.Empty;
118122
private bool _isCopied = false;
119123
private DispatcherTimer _resetTimer = null;
120124
}

0 commit comments

Comments
 (0)