1111*
1212\*====================================================================================*/
1313
14+ using OpenSilver . Internal ;
1415using System . Windows . Controls . Primitives ;
1516
1617namespace System . Windows . Controls
@@ -36,21 +37,28 @@ static ToolTip()
3637 public ToolTip ( ) { }
3738
3839 /// <summary>
39- /// Gets or sets a value that indicates whether the ToolTip is visible. True if the ToolTip is visible; otherwise, false. The default is false .
40+ /// Gets or sets a value that indicates whether the <see cref=" ToolTip"/> is visible.
4041 /// </summary>
42+ /// <returns>
43+ /// true if the <see cref="ToolTip"/> is visible; otherwise, false. The default is false.
44+ /// </returns>
4145 public bool IsOpen
4246 {
43- get { return ( bool ) GetValue ( IsOpenProperty ) ; }
44- set { SetValueInternal ( IsOpenProperty , value ) ; }
47+ get => ( bool ) GetValue ( IsOpenProperty ) ;
48+ set => SetValueInternal ( IsOpenProperty , value ) ;
4549 }
4650
4751 /// <summary>
48- /// Identifies the IsOpen dependency property.
52+ /// Identifies the <see cref=" IsOpen"/> dependency property.
4953 /// </summary>
5054 public static readonly DependencyProperty IsOpenProperty =
51- DependencyProperty . Register ( nameof ( IsOpen ) , typeof ( bool ) , typeof ( ToolTip ) , new PropertyMetadata ( false , IsOpen_Changed ) ) ;
55+ DependencyProperty . Register (
56+ nameof ( IsOpen ) ,
57+ typeof ( bool ) ,
58+ typeof ( ToolTip ) ,
59+ new PropertyMetadata ( BooleanBoxes . FalseBox , OnIsOpenChanged ) ) ;
5260
53- private static void IsOpen_Changed ( DependencyObject d , DependencyPropertyChangedEventArgs e )
61+ private static void OnIsOpenChanged ( DependencyObject d , DependencyPropertyChangedEventArgs e )
5462 {
5563 ( ( ToolTip ) d ) . UpdatePopup ( ( bool ) e . NewValue ) ;
5664 }
@@ -141,12 +149,12 @@ private void OnOwnerDataContextChanged(object sender, DependencyPropertyChangedE
141149 }
142150
143151 /// <summary>
144- /// Occurs when a ToolTip is closed and is no longer visible.
152+ /// Occurs when a <see cref=" ToolTip"/> is closed and is no longer visible.
145153 /// </summary>
146154 public event RoutedEventHandler Closed ;
147155
148156 /// <summary>
149- /// Occurs when a ToolTip becomes visible.
157+ /// Occurs when a <see cref=" ToolTip"/> becomes visible.
150158 /// </summary>
151159 public event RoutedEventHandler Opened ;
152160
@@ -157,18 +165,17 @@ private void OnOwnerDataContextChanged(object sender, DependencyPropertyChangedE
157165 ToolTipService . PlacementTargetProperty . AddOwner ( typeof ( ToolTip ) ) ;
158166
159167 /// <summary>
160- /// Gets or sets the visual element or control that the tool tip should be
161- /// positioned in relation to when opened by the <see cref="ToolTipService" />.
168+ /// Gets or sets the visual element or control that the tool tip should be positioned in relation to
169+ /// when opened by the <see cref="ToolTipService" />.
162170 /// </summary>
163171 /// <returns>
164- /// The visual element or control that the tool tip should be positioned in
165- /// relation to when opened by the <see cref="ToolTipService" />.
166- /// The default is null.
172+ /// The visual element or control that the tool tip should be positioned in relation to when opened
173+ /// by the <see cref="ToolTipService" />. The default is null.
167174 /// </returns>
168175 public UIElement PlacementTarget
169176 {
170- get { return ( UIElement ) GetValue ( PlacementTargetProperty ) ; }
171- set { SetValueInternal ( PlacementTargetProperty , value ) ; }
177+ get => ( UIElement ) GetValue ( PlacementTargetProperty ) ;
178+ set => SetValueInternal ( PlacementTargetProperty , value ) ;
172179 }
173180
174181 private UIElement EffectivePlacementTarget
@@ -191,17 +198,15 @@ private UIElement EffectivePlacementTarget
191198 ToolTipService . PlacementProperty . AddOwner ( typeof ( ToolTip ) ) ;
192199
193200 /// <summary>
194- /// Gets or sets how the <see cref="ToolTip" /> should be positioned
195- /// in relation to the <see cref="PlacementTarget" />.
201+ /// Gets or sets how the <see cref="ToolTip" /> should be positioned in relation to the <see cref="PlacementTarget" />.
196202 /// </summary>
197203 /// <returns>
198- /// One of the <see cref="PlacementMode" /> values.
199- /// The default is <see cref="PlacementMode.Mouse" />.
204+ /// One of the <see cref="PlacementMode" /> values. The default is <see cref="PlacementMode.Mouse" />.
200205 /// </returns>
201206 public PlacementMode Placement
202207 {
203- get { return ( PlacementMode ) GetValue ( PlacementProperty ) ; }
204- set { SetValueInternal ( PlacementProperty , value ) ; }
208+ get => ( PlacementMode ) GetValue ( PlacementProperty ) ;
209+ set => SetValueInternal ( PlacementProperty , value ) ;
205210 }
206211
207212 private PlacementMode EffectivePlacement
@@ -217,41 +222,66 @@ private PlacementMode EffectivePlacement
217222 }
218223 }
219224
220- //-----------------------
221- // HORIZONTALOFFSET
222- //-----------------------
223-
224225 /// <summary>
225- /// Gets or sets the horizontal distance between the target origin and the pop-up alignment point. The default is 0.
226+ /// Gets or sets the horizontal distance between the target origin and the pop-up alignment point.
226227 /// </summary>
228+ /// <returns>
229+ /// The horizontal distance between the target origin and the pop-up alignment point. The default is 0.
230+ /// </returns>
227231 public double HorizontalOffset
228232 {
229- get { return ( double ) GetValue ( HorizontalOffsetProperty ) ; }
230- set { SetValueInternal ( HorizontalOffsetProperty , value ) ; }
233+ get => ( double ) GetValue ( HorizontalOffsetProperty ) ;
234+ set => SetValueInternal ( HorizontalOffsetProperty , value ) ;
231235 }
236+
232237 /// <summary>
233- /// Identifies the HorizontalOffset dependency property.
238+ /// Identifies the <see cref=" HorizontalOffset"/> dependency property.
234239 /// </summary>
235240 public static readonly DependencyProperty HorizontalOffsetProperty =
236- DependencyProperty . Register ( nameof ( HorizontalOffset ) , typeof ( double ) , typeof ( ToolTip ) , new PropertyMetadata ( 0d ) ) ;
237-
241+ DependencyProperty . Register (
242+ nameof ( HorizontalOffset ) ,
243+ typeof ( double ) ,
244+ typeof ( ToolTip ) ,
245+ new PropertyMetadata ( 0d , OnHorizontalOffsetChanged ) ) ;
238246
239- //-----------------------
240- // VERTICALOFFSET
241- //-----------------------
247+ private static void OnHorizontalOffsetChanged ( DependencyObject o , DependencyPropertyChangedEventArgs e )
248+ {
249+ var tooltip = ( ToolTip ) o ;
250+ if ( tooltip . _parentPopup is not null )
251+ {
252+ tooltip . _parentPopup . HorizontalOffset = ( double ) e . NewValue ;
253+ }
254+ }
242255
243256 /// <summary>
244- /// Gets or sets the vertical distance between the target origin and the pop-up alignment point. The default is 0.
257+ /// Gets or sets the vertical distance between the target origin and the pop-up alignment point.
245258 /// </summary>
259+ /// <returns>
260+ /// The vertical distance between the target origin and the pop-up alignment point. The default is 0.
261+ /// </returns>
246262 public double VerticalOffset
247263 {
248- get { return ( double ) GetValue ( VerticalOffsetProperty ) ; }
249- set { SetValueInternal ( VerticalOffsetProperty , value ) ; }
264+ get => ( double ) GetValue ( VerticalOffsetProperty ) ;
265+ set => SetValueInternal ( VerticalOffsetProperty , value ) ;
250266 }
267+
251268 /// <summary>
252- /// Identifies the VerticalOffset dependency property.
269+ /// Identifies the <see cref=" VerticalOffset"/> dependency property.
253270 /// </summary>
254271 public static readonly DependencyProperty VerticalOffsetProperty =
255- DependencyProperty . Register ( nameof ( VerticalOffset ) , typeof ( double ) , typeof ( ToolTip ) , new PropertyMetadata ( 0d ) ) ;
272+ DependencyProperty . Register (
273+ nameof ( VerticalOffset ) ,
274+ typeof ( double ) ,
275+ typeof ( ToolTip ) ,
276+ new PropertyMetadata ( 0d , OnVerticalOffsetChanged ) ) ;
277+
278+ private static void OnVerticalOffsetChanged ( DependencyObject o , DependencyPropertyChangedEventArgs e )
279+ {
280+ var tooltip = ( ToolTip ) o ;
281+ if ( tooltip . _parentPopup is not null )
282+ {
283+ tooltip . _parentPopup . VerticalOffset = ( double ) e . NewValue ;
284+ }
285+ }
256286 }
257287}
0 commit comments