Created
May 24, 2023 06:59
-
-
Save xantilon/a98dd7d5936aafb116367d003844b8c3 to your computer and use it in GitHub Desktop.
see ![in action](https://i.imgur.com/aSnqp6E.png)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class OutlineLabel : Control,INotifyPropertyChanged | |
{ | |
public static readonly DependencyProperty OutlineForeColorProperty = | |
DependencyProperty.Register ("OutlineForeColor", typeof (Color), typeof (OutlineLabel), new PropertyMetadata (Colors.Green)); | |
public static readonly DependencyProperty OutlineWidthProperty = | |
DependencyProperty.Register ("OutlineWidth", typeof (double), typeof (OutlineLabel), new PropertyMetadata (2.0)); | |
public static readonly DependencyProperty TextProperty = | |
DependencyProperty.Register ("Text", typeof (string), typeof (OutlineLabel), | |
new FrameworkPropertyMetadata (null, | |
FrameworkPropertyMetadataOptions.AffectsRender | | |
FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, | |
CustomTextBox_OnTextPropertyChanged)); | |
private static void CustomTextBox_OnTextPropertyChanged(DependencyObject d, | |
DependencyPropertyChangedEventArgs e) | |
{ | |
OutlineLabel outlineLabel = d as OutlineLabel; | |
outlineLabel.SetValue (TextProperty, e.NewValue); | |
outlineLabel.Text = e.NewValue.ToString (); | |
outlineLabel.UpdateLayout(); | |
} | |
//public OutlineLabel() | |
//{ | |
// // DefaultStyleKey = typeof (OutlineLabel); | |
// DefaultStyleKeyProperty.OverrideMetadata(typeof (OutlineLabel), | |
// new FrameworkPropertyMetadata (typeof (OutlineLabel))); | |
//} | |
public Color OutlineForeColor | |
{ | |
get { return (Color)GetValue (OutlineForeColorProperty); } | |
set { SetValue (OutlineForeColorProperty, value); } | |
} | |
public double OutlineWidth | |
{ | |
get { return (double)GetValue (OutlineWidthProperty); } | |
set { SetValue (OutlineWidthProperty, value); } | |
} | |
public string Text | |
{ | |
get { r |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment