Solved

C#, WPF Grid, and WindowsFormsHost

Posted on 2008-10-15
2
1,804 Views
Last Modified: 2013-12-17
I have a WPF Window that has a 1X2 Grid.  I want to host a WinForm in each cell of the grid.  I have seen how to do this with [this.grid1.Children.Add(host);] and that works for the first cell.  How do I host a WinForm in the second cell?
0
Comment
Question by:Henrici
2 Comments
 
LVL 5

Accepted Solution

by:
rendaduiyan earned 125 total points
ID: 22727796
easy. modify your XAML.
<Window x:Class="WpfApplication1.Window1"

    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

    Title="Window1" Height="300" Width="300" xmlns:my="clr-namespace:System.Windows.Forms.Integration;assembly=WindowsFormsIntegration">

    <Grid x:Name="MainGrid">

        <Grid.ColumnDefinitions>

            <ColumnDefinition Width="0.5*"/>

            <ColumnDefinition Width="0.5*"/>

        </Grid.ColumnDefinitions>

        <my:WindowsFormsHost Grid.Column="0" Margin="0,0,0,0" Name="windowsFormsHost1" />

        <my:WindowsFormsHost Grid.Column="1" Margin="0,0,0,0" Name="windowsFormsHost1" />

    </Grid>

</Window>

Open in new window

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Loop not working 29 47
Get list of word ducuments in a folder 10 35
Open a word document 23 33
SSL https .net web site force redirect 3 34
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Delivering innovative fully-managed cloud services for mission-critical applications requires expertise in multiple areas plus vision and commitment. Meet a few of the people behind the quality services of Concerto.

914 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now