Skip to content

Commit e7f0217

Browse files
committed
refactor: move binding for ToolTip.IsOpen from code to axaml
Signed-off-by: leo <[email protected]>
1 parent 0cb2ca7 commit e7f0217

File tree

2 files changed

+7
-17
lines changed

2 files changed

+7
-17
lines changed

src/Views/CommitBaseInfo.axaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,13 @@
203203
FullMessage="{Binding #ThisControl.FullMessage}"
204204
HorizontalAlignment="Stretch"
205205
TextWrapping="Wrap">
206+
<ToolTip.IsOpen>
207+
<MultiBinding Converter="{x:Static BoolConverters.And}">
208+
<Binding Path="$self.IsPointerOver"/>
209+
<Binding Path="$self.(ToolTip.Tip)" Converter="{x:Static ObjectConverters.IsNotNull}"/>
210+
</MultiBinding>
211+
</ToolTip.IsOpen>
212+
206213
<v:CommitMessagePresenter.DataTemplates>
207214
<DataTemplate DataType="m:Commit">
208215
<StackPanel MinWidth="400" Orientation="Vertical">

src/Views/CommitMessagePresenter.cs

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
using Avalonia;
66
using Avalonia.Controls;
77
using Avalonia.Controls.Documents;
8-
using Avalonia.Data;
9-
using Avalonia.Data.Converters;
108
using Avalonia.Input;
119
using Avalonia.Threading;
1210
using Avalonia.VisualTree;
@@ -26,21 +24,6 @@ public Models.CommitFullMessage FullMessage
2624

2725
protected override Type StyleKeyOverride => typeof(SelectableTextBlock);
2826

29-
public CommitMessagePresenter()
30-
{
31-
var bindings = new MultiBinding()
32-
{
33-
Converter = BoolConverters.And,
34-
Bindings = new[]
35-
{
36-
new Binding() { Path = "IsPointerOver", Source = this },
37-
new Binding() { Path = "(ToolTip.Tip)", Source = this, TypeResolver = (_, name) => name == "ToolTip" ? typeof(ToolTip) : null, Converter = ObjectConverters.IsNotNull },
38-
}
39-
};
40-
41-
Bind(ToolTip.IsOpenProperty, bindings);
42-
}
43-
4427
protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change)
4528
{
4629
base.OnPropertyChanged(change);

0 commit comments

Comments
 (0)