Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

Wpf ListBox Hosting Windows Form Contols : Drawing Problem

$
0
0

Hi All,

I have a windows form image control(For Demonstration purpose, basically it is a WindowForm UserControl Hosting ActiveX Flash Player Control. ) inside  WFP - ListBox,

When i am scrolling Down and Up in ListBox. Windows form control is not Drawing correctly, it is going out of the ListBox..

XAML Code...

<Window x:Class="WPF_Demos.Window3"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:UC="clr-namespace:WPF_Demos"
        xmlns:win="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"
        Title="Window3" Height="500" Width="500"><!-- Set the ItemTemplate of the ListBox to a DataTemplate which
                explains how to display an object of type BitmapImage. --><Window.Resources><Style TargetType="{x:Type ListBox}"><Setter Property="ItemTemplate"><Setter.Value><DataTemplate><StackPanel><WindowsFormsHost x:Name="winhost"><win:PictureBox x:Name="picbox"  Width="200" Height="200" SizeMode="StretchImage" ImageLocation="C:\DOTNET\WPF\WPF_Demos\WPF_Demos\Images\Desert.jpg"/></WindowsFormsHost></StackPanel></DataTemplate></Setter.Value></Setter><Setter Property="ItemsPanel"><Setter.Value><ItemsPanelTemplate><WrapPanel /></ItemsPanelTemplate></Setter.Value></Setter><Setter
                    Property="ScrollViewer.HorizontalScrollBarVisibility"
                    Value="Disabled"
                /></Style></Window.Resources><Grid><ListBox x:Name="lstImgs" ScrollBar.Scroll="lstImgs_Scroll" Margin="100"  ListBox.MouseDoubleClick="StackPanel_MouseDoubleClick" ItemsSource="{Binding }"/></Grid></Window>

C# Code:

 this.DataContext = System.Linq.Enumerable.Range(0, 30);

I have read lots of article 

http://bartwullems.blogspot.in/2010/11/wpf-and-winforms-airspace-problem.html

After reading this article i got to how to solve AirSpace Problem when u have single control. Not like ListBox hosting Multiple WindowsForm Control.

and I have read this forum thread ....

http://social.msdn.microsoft.com/forums/en-US/wpf/thread/1e1a9728-1b1b-4336-afe7-5513c1beb3cc

I want to know that how to solve this problem.

please help me...


Vikas Gupta


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>