I have a Windows Forms application in which I host a usercontrol created with WPF. This is done using the Element Host class. All WPF elements in the element host container inherit the windows forms style, including fonts, etc.

I want to prevent that from happening. All elements should inherit the default WPF style, so the fonts (and other styles) are the same. How can I achieve that?

I do not want to set all defaults myself.

Example Window Example Window, note the difference between the 'g' in 'segeo' and 'S' in 'MS Sans Serif'

有帮助吗?

解决方案

Found it:

Just add:

this.InheritanceBehavior = InheritanceBehavior.SkipToAppNext;

to your constructor of your UserControl.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top