Skip to content

Instantly share code, notes, and snippets.

@xantilon
Created May 24, 2023 06:59
Show Gist options
  • Save xantilon/a98dd7d5936aafb116367d003844b8c3 to your computer and use it in GitHub Desktop.
Save xantilon/a98dd7d5936aafb116367d003844b8c3 to your computer and use it in GitHub Desktop.
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