Solved

C#, WPF Grid, and WindowsFormsHost

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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
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…
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…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

708 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

17 Experts available now in Live!

Get 1:1 Help Now