There is a workaround for you to add some custom Dependency Properties for your MovableTextbox which inherited from Textbox. You can create a class which inherit from DependencyObject to declare your custom Dependency Properties and use it like local:className.propertyName in the customControl. I will give you a demo to use it.
Here is the class:
public class RotationManager : DependencyObject
{
public static double GetAngle(DependencyObject obj)
{
return (double)obj.GetValue(AngleProperty);
}
public static void SetAngle(DependencyObject obj, double value)
{
obj.SetValue(AngleProperty, value);
}
public static readonly DependencyProperty AngleProperty =
DependencyProperty.RegisterAttached("Angle", typeof(double), typeof(RotationManager), new PropertyMetadata(0.0, OnAngleChanged));
private static void OnAngleChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e)
{
var element = obj as UIElement;
if (element != null)
{
element.RenderTransformOrigin = new Point(0.5, 0.5);
element.RenderTransform = new RotateTransform((double)e.NewValue);
}
}
}
The custom control code is:
public class MyTextBox:TextBox
{
private bool m_underLine;
public bool UnderLine
{
get { return m_underLine; }
set
{
if (this.m_underLine != value)
{
if (value)
{
this.TextDecorations = System.Windows.TextDecorations.Underline;
}
m_underLine = value;
}
}
}
}
You can use it in the custom control like:
<local:MyTextBox UnderLine="True" local:RotationManager.Angle="60"
Width="400" Height="80"
Text="This is my custome TextBox"
></local:MyTextBox>