WPF Style Inheritance Behavior

Recently I was using a window style with MahAppsMetro, now it applies the styles at application level. One of the things I am doing is embedding AvalonEdit in one such window. Now with Metro styling it applies styles to the controls and in my case SearchPanel in AvalonEdit was styled too! This is fine, but the results were quite un-expected:

Metro Styling applied to SearchPanel

Metro Styling applied to SearchPanel

Now, of course I do want to keep Metro Style for my application, however want to keep AvalonEdit styling intact as well.

Thinking further the simplest thing to do would be to be to somehow disable inheritance of styles at some level. I found a post on stackoverflow discussing this. However for me it was not to stop inheriting styles but to fallback to theme. Documentation on this topic is pretty scarce.

Now to get things to work, I wrapped the AvalonEdit.TextEditor in a custom Control which would InheritanceBehavior.SkipToThemeNow.



[Read More]