wpftextboxcolorsbackgroundsystemcolors

Reset TextBox.Background to default in WPF so it still gets updated when system settings change


I have a TextBox that I wish to reset its Background property to its default value after changing it to a different colour.

I have tried setting it to SystemColors.WindowBrush, but then, if the Display Settings are updated to change this value, it doesn't get dynamically reflected in the TextBox (it does normally if TextBox.Background hasn't been touched).

Any idea how to do this?


Solution

  • From what I understand of WPF's binding system, setting it to DependencyProperty.UnsetValue should revert it to WPF figuring out what to do with it.