Hosting a WPF control in Winform with a scrollable Panel
I have a winform project that uses a WPF control for reports. Everything went good, until we need to add more report to a form, and requirements told us to create a scrollbar to show all reports. I simply put a panel with autoscroll = true, and inside it I put a TableLayoutPanel and everything seems to works, excepts that ElementHost used to wrap the WPF controls when scrolled shows a messy interface.
Figure 1: Messy interface with WPF report when I scroll the panel
This is due to a bad iteration between the panel and the contained ElementHost, because when the panels scrolls the TableLayoutPanel noone tells the hostControl to refresh. The solution is obvious, handle the Scroll event of the Panel:
|
|
I simply manually call Refresh for every ElementHost to force refresh of WPF control hosted in it.
alk.