Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit b11156b

Browse files
committed
Create and release tooltip content on demand
Save memory by not holding on to contents of tooltip (comment thread).
1 parent fc8d0f7 commit b11156b

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

src/GitHub.InlineReviews/Tags/ShowInlineCommentGlyph.xaml.cs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,17 @@ namespace GitHub.InlineReviews.Tags
77
{
88
public partial class ShowInlineCommentGlyph : UserControl
99
{
10-
readonly CommentTooltipView commentTooltipView;
10+
readonly ToolTip toolTip;
1111

1212
public ShowInlineCommentGlyph()
1313
{
1414
InitializeComponent();
1515

16-
commentTooltipView = new CommentTooltipView();
17-
ToolTip = commentTooltipView;
18-
ToolTipOpening += ShowInlineCommentGlyph_ToolTipOpening;
16+
toolTip = new ToolTip();
17+
ToolTip = toolTip;
1918
}
2019

21-
private void ShowInlineCommentGlyph_ToolTipOpening(object sender, ToolTipEventArgs e)
20+
protected override void OnToolTipOpening(ToolTipEventArgs e)
2221
{
2322
var tag = Tag as ShowInlineCommentTag;
2423

@@ -29,7 +28,15 @@ private void ShowInlineCommentGlyph_ToolTipOpening(object sender, ToolTipEventAr
2928
viewModel.Comments.Add(commentViewModel);
3029
}
3130

32-
commentTooltipView.DataContext = viewModel;
31+
var view = new CommentTooltipView();
32+
view.DataContext = viewModel;
33+
34+
toolTip.Content = view;
35+
}
36+
37+
protected override void OnToolTipClosing(ToolTipEventArgs e)
38+
{
39+
toolTip.Content = null;
3340
}
3441
}
3542
}

0 commit comments

Comments
 (0)