How can I use a WindowsFormsHost element to host a System.Windows.Forms ?

Platform: WPF| Category: Windows Forms and WPF

It can be done with the following code :

[XAML]

<Window x:Class='HostingWfInWpf.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'  
    Title='HostingWfInWpf'
    >
    <Grid>
        <WindowsFormsHost>
            <wf:MaskedTextBox x:Name='mtbDate' Mask='00/00/0000'/>
        </WindowsFormsHost>
    </Grid>  
</Window>

Share with

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.