winforms - WindowsFormHost items in a WPF ListBox - Z-Order -
i have been end of web , , can't seem find solution z-ordering windowsformshost issue. issue specific rendering listbox items windowsformshost wrapped winform controls. when rendered items displayed outside bounds of listbox -- makes entire screen horrible.
i attaching quick code sample. have options? need rethink layout?
<window x:class="wfh_zorderissue.window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:wf="clr-namespace:system.windows.forms;assembly=system.windows.forms" xmlns:wfi="clr-namespace:system.windows.forms.integration;assembly=windowsformsintegration" title="wfh listbox zorder" height="300" width="600"> <grid> <listbox background="lightblue" horizontalalignment="left" itemssource="{binding}" maxwidth="400" borderthickness="0" scrollviewer.verticalscrollbarvisibility="hidden" scrollviewer.cancontentscroll="false" scrollviewer.horizontalscrollbarvisibility="auto" selectionmode="extended" x:name="lstdisplays" > <listbox.itemtemplate> <datatemplate> <scrollviewer x:name="viewer" verticalscrollbarvisibility="hidden" > <wfi:windowsformshost margin="20,0" x:name="host"> <wf:button text="windowformshost - ugly" /> </wfi:windowsformshost> </scrollviewer> </datatemplate> </listbox.itemtemplate> <listbox.itemspanel> <itemspaneltemplate> <stackpanel orientation="horizontal" /> </itemspaneltemplate> </listbox.itemspanel> </listbox> </grid> </window>
and codebehind:
/// <summary> /// interaction logic window1.xaml /// </summary> public partial class window1 : window { public window1() { initializecomponent(); this.datacontext = system.linq.enumerable.range(0, 30); } }
please :)
this known airspace issue. winforms render above wpf since both use different rendering technologies. there few solutions around not straight forward.
have @ this blog entry or here might able working.
if doesn't work suggest not place winforms anywhere lower top level (i.e. on window) , make sure not fancy layouts.
Comments
Post a Comment