Note that there are some explanatory texts on larger screens.

plurals
  1. POWindowsFormHost items in a WPF ListBox - Z-Order
    primarykey
    data
    text
    <p>I have been to the end of the web and back and I can't seem to find any solution for my Z-Ordering WindowsFormsHost Issue. My issue is specific to rendering a ListBox where the items are WindowsFormsHost wrapped WinForm controls. When rendered all the items are displayed even those outside the bounds of the ListBox -- which makes the entire screen look horrible. </p> <p>I am attaching a quick code sample. Do I have any options? Do I need to rethink my layout?</p> <pre><code> &lt;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"&gt; &lt;Grid&gt; &lt;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" &gt; &lt;ListBox.ItemTemplate&gt; &lt;DataTemplate&gt; &lt;ScrollViewer x:Name="viewer" VerticalScrollBarVisibility="Hidden" &gt; &lt;wfi:WindowsFormsHost Margin="20,0" x:Name="host"&gt; &lt;wf:Button Text="WindowFormsHost - The Ugly" /&gt; &lt;/wfi:WindowsFormsHost&gt; &lt;/ScrollViewer&gt; &lt;/DataTemplate&gt; &lt;/ListBox.ItemTemplate&gt; &lt;ListBox.ItemsPanel&gt; &lt;ItemsPanelTemplate&gt; &lt;StackPanel Orientation="Horizontal" /&gt; &lt;/ItemsPanelTemplate&gt; &lt;/ListBox.ItemsPanel&gt; &lt;/ListBox&gt; &lt;/Grid&gt; &lt;/Window&gt; </code></pre> <p>and the codebehind:</p> <pre><code> /// &lt;summary&gt; /// Interaction logic for Window1.xaml /// &lt;/summary&gt; public partial class Window1 : Window { public Window1() { InitializeComponent(); this.DataContext = System.Linq.Enumerable.Range(0, 30); } } </code></pre> <p>Please help :)</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload