diff options
Diffstat (limited to 'Software/Visual_Studio/Tango.SharedUI/Controls/FastTextBlock.cs')
| -rw-r--r-- | Software/Visual_Studio/Tango.SharedUI/Controls/FastTextBlock.cs | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/Software/Visual_Studio/Tango.SharedUI/Controls/FastTextBlock.cs b/Software/Visual_Studio/Tango.SharedUI/Controls/FastTextBlock.cs index 5b2808ab1..141fa6e27 100644 --- a/Software/Visual_Studio/Tango.SharedUI/Controls/FastTextBlock.cs +++ b/Software/Visual_Studio/Tango.SharedUI/Controls/FastTextBlock.cs @@ -9,6 +9,7 @@ using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; +using System.Windows.Markup; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; @@ -16,14 +17,24 @@ using System.Windows.Shapes; namespace Tango.SharedUI.Controls { - + [ContentProperty(nameof(Text))] public class FastTextBlock : Control { private FormattedText _formattedText; static FastTextBlock() { - + + } + + public FastTextBlock() + { + Loaded += FastTextBlock_Loaded; + } + + private void FastTextBlock_Loaded(object sender, RoutedEventArgs e) + { + Init(); } public static readonly DependencyProperty TextProperty = @@ -31,19 +42,24 @@ namespace Tango.SharedUI.Controls "Text", typeof(string), typeof(FastTextBlock), - new FrameworkPropertyMetadata(string.Empty, FrameworkPropertyMetadataOptions.AffectsMeasure, + new FrameworkPropertyMetadata(string.Empty, FrameworkPropertyMetadataOptions.AffectsMeasure | FrameworkPropertyMetadataOptions.AffectsRender, (o, e) => ((FastTextBlock)o).TextPropertyChanged((string)e.NewValue))); private void TextPropertyChanged(string text) { - if (text != null) + Init(); + } + + private void Init() + { + if (Text != null) { var typeface = new Typeface( FontFamily, - FontStyles.Normal, FontWeights.Normal, FontStretches.Normal); + FontStyle, FontWeight, FontStretch); _formattedText = new FormattedText( - text, CultureInfo.CurrentCulture, + Text, CultureInfo.CurrentCulture, FlowDirection.LeftToRight, typeface, FontSize, Foreground); } } |
