简体   繁体   中英

Load WinForms DataGridView to a WPF control

I have a custom class inheriting from WinForms's DataGridView. It's got it's own styles and probably some custom behavior too. I'm supposed to create a UserControl which has to contain this custom DGV. I'd rather use WPF for that, but unless I find a way to use this DGV in it I'll have to stay with WinForms.

Is there a workaround?

see for WindowsFormsHost . this will host any winform control for you in wpf. you can find a good sample here

http://www.c-sharpcorner.com/uploadfile/mahesh/using-windows-forms-controls-in-wpf/

for example.

<Grid>
            <WindowsFormsHost>
                <wf:ListBox x:Name="lstBox"/>
            </WindowsFormsHost>         
 </Grid>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM