views:

13

answers:

0

Hi, I want to underline a text element programmatically in C# (I'm using WPF). I have a DependencyProperty:

 public TextDecorationCollection TextDecoration
        {
            get { return (TextDecorationCollection)GetValue(TextDecorationProperty); }
            set { SetValue(TextDecorationProperty, value); }
        }
   public static DependencyProperty TextDecorationProperty = DependencyProperty.Register(
            "TextDecoration",
            typeof(TextDecorationCollection),
            typeof(TextStyleVM),
            new UIPropertyMetadata());

And I have a Command that gets called everytime the Underlined-ToggleButton gets pushed:

 private void ChangeUnderlined(bool p)
        {
            TextDecorationCollection tdc = new TextDecorationCollection(TextDecorations.Underline);

            if (p)
                TextDecoration = tdc;
            else
                TextDecoration = null;    
        }

My Problem is the Text doesn't change, it doesn't get underlined.