6
6
7
7
namespace GitHub . InlineReviews . Peek
8
8
{
9
- class InlineCommentPeekResultPresentation : IPeekResultPresentation
9
+ class InlineCommentPeekResultPresentation : IPeekResultPresentation , IDesiredHeightProvider
10
10
{
11
+ const double PeekBorders = 28.0 ;
11
12
readonly InlineCommentPeekViewModel viewModel ;
13
+ InlineCommentPeekView view ;
14
+ double desiredHeight ;
12
15
13
16
public bool IsDirty => false ;
14
17
public bool IsReadOnly => true ;
@@ -24,9 +27,23 @@ public double ZoomLevel
24
27
set { }
25
28
}
26
29
30
+ public double DesiredHeight
31
+ {
32
+ get { return desiredHeight ; }
33
+ private set
34
+ {
35
+ if ( desiredHeight != value && DesiredHeightChanged != null )
36
+ {
37
+ desiredHeight = value ;
38
+ DesiredHeightChanged ( this , EventArgs . Empty ) ;
39
+ }
40
+ }
41
+ }
42
+
27
43
public event EventHandler IsDirtyChanged ;
28
44
public event EventHandler IsReadOnlyChanged ;
29
45
public event EventHandler < RecreateContentEventArgs > RecreateContent ;
46
+ public event EventHandler < EventArgs > DesiredHeightChanged ;
30
47
31
48
public bool CanSave ( out string defaultPath )
32
49
{
@@ -45,8 +62,15 @@ public void Close()
45
62
46
63
public UIElement Create ( IPeekSession session , IPeekResultScrollState scrollState )
47
64
{
48
- var view = new InlineCommentPeekView ( ) ;
65
+ view = new InlineCommentPeekView ( ) ;
49
66
view . DataContext = viewModel ;
67
+
68
+ // Report the desired size back to the peek view. Unfortunately the peek view
69
+ // helpfully assigns this desired size to the control that also contains the tab at
70
+ // the top of the peek view, so we need to put in a fudge factor. Using a const
71
+ // value for the moment, as there's no easy way to get the size of the control.
72
+ view . DesiredHeight . Subscribe ( x => DesiredHeight = x + PeekBorders ) ;
73
+
50
74
return view ;
51
75
}
52
76
0 commit comments