Solved

C#, WPF Grid, and WindowsFormsHost

Posted on 2008-10-15
2
1,815 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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

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 …
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
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…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

821 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