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

Commit 7a3eead

Browse files
committed
Set the InlineCommentTag as glyph's DataContext
This will let the look of the glyph chance according to its tag.
1 parent ed75ca2 commit 7a3eead

File tree

2 files changed

+14
-11
lines changed

2 files changed

+14
-11
lines changed

src/GitHub.InlineReviews/Tags/InlineCommentGlyphFactory.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ static Brush GetBackground(ResourceDictionary dictionary)
6969
public UIElement GenerateGlyph(IWpfTextViewLine line, InlineCommentTag tag)
7070
{
7171
var glyph = CreateGlyph(tag);
72-
glyph.Tag = tag;
72+
glyph.DataContext = tag;
7373

7474
glyph.MouseLeftButtonUp += (s, e) =>
7575
{

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

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,22 @@ public ShowInlineCommentGlyph()
1616

1717
protected override void OnToolTipOpening(ToolTipEventArgs e)
1818
{
19-
var tag = Tag as ShowInlineCommentTag;
20-
var comments = tag.Thread.Comments.Select(comment => new PullRequestReviewCommentModel
19+
var tag = DataContext as ShowInlineCommentTag;
20+
if (tag != null)
2121
{
22-
User = comment.User,
23-
Body = comment.Body,
24-
CreatedAt = comment.CreatedAt
25-
});
22+
var comments = tag.Thread.Comments.Select(comment => new PullRequestReviewCommentModel
23+
{
24+
User = comment.User,
25+
Body = comment.Body,
26+
CreatedAt = comment.CreatedAt
27+
});
2628

27-
var viewModel = new TooltipCommentThreadViewModel(comments);
28-
var view = new TooltipCommentThreadView();
29-
view.DataContext = viewModel;
29+
var viewModel = new TooltipCommentThreadViewModel(comments);
30+
var view = new TooltipCommentThreadView();
31+
view.DataContext = viewModel;
3032

31-
CommentToolTip.Content = view;
33+
CommentToolTip.Content = view;
34+
}
3235
}
3336

3437
protected override void OnToolTipClosing(ToolTipEventArgs e)

0 commit comments

Comments
 (0)