Create "Inlines"-Property for custom TextBlock-Control?
-
Thursday, March 15, 2012 11:32 AM
Hello!
I've created my own custom TextBlock-Control, which works so far and now I would like to add "Run"-Elements to the Inlines-Property in codebehind. But the Inlines-Property don't exist in my control at the moment and my question is, what I must do to have the same property and behaviour in my control?
Here is my code:
using System.Windows.Controls; using System.ComponentModel; using System.Windows; namespace My_Controls.Controls { [Description("Textblock BaseClass"), Category("Common Properties")] public class My_TextBlock : Control { public My_TextBlock() { this.DefaultStyleKey = typeof(My_TextBlock); this.FontFamily = new System.Windows.Media.FontFamily("Arial"); this.FontSize = 11; } public static readonly DependencyProperty TextProperty = DependencyProperty.Register("Text", typeof(string), typeof(My_TextBlock), new PropertyMetadata(" ")); [Description("Text Property."), Category("Common Properties")] public string Text { get { return GetValue(TextProperty) as string; } set { SetValue(TextProperty, value); } } public string Content { get { return this.Text; } set { this.Text = value; } } public override void OnApplyTemplate() { base.OnApplyTemplate(); } } }Thank you in advance for your answers!
Best Regards
Malone

