-
Notifications
You must be signed in to change notification settings - Fork 66
/
Copy pathTextBlockHelper.cs
30 lines (29 loc) · 912 Bytes
/
TextBlockHelper.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
namespace AmCharts.Windows.QuickCharts
{
/// <summary>
/// Helps unify handling of differing aspects of TextBlock in Silvelright and WPF.
/// </summary>
public static class TextBlockHelper
{
/// <summary>
/// Workaround for a Silverlight issue when DesiredSize is not set after a call to Measure()
/// but ActualWidth and ActualHeight are set instead.
/// </summary>
/// <param name="textBlock">TextBlock</param>
/// <returns>Size of the TextBlock</returns>
public static Size GetDesiredSize(this TextBlock textBlock)
{
#if SILVERLIGHT
return new Size(textBlock.ActualWidth, textBlock.ActualHeight);
#else
return textBlock.DesiredSize;
#endif
}
}
}