Felix  RuthenbergReset WPF Dependency Property


We have seen how dependency properties inherit their values from another control they are nested in.  We also saw that it's possible to break that chain of inheritance by setting the value of a certain property specifically.

But what can we do to reset the Dependency Property again, so that inherits its value from a higher hierachy level again?  The answer is quite simple and done within one or two lines of code using the ClearValue() method of the control.

ClearValue() expects a parameter that tells which dependency property is to be reset as the following example shows:

private void Button_MouseRightButtonUp(object sender, MouseButtonEventArgs e)
{
  Button btn = e.Source as Button;
  btn.ClearValue(Button.FontSizeProperty);
}


Kategorien: WPF; 22.01.2009 09:08:32


 


Neuen Kommentar einfügen:

  Titel:   
  Name:
  E-Mail:
  Kommentar:

 
 


Kommentare




© Copyright 2008 ppedv AG