开发者

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

开发者 https://www.devze.com 2022-12-31 06:15 出处:网络
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 开发者_如何转开发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?


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.


for Wpf this line work for me:

TextBox1.ClearValue(TextBox.BackgroundProperty);
0

精彩评论

暂无评论...
验证码 换一张
取 消