views:

29

answers:

1

I'm using WPF 4.0. I have a WPF Datagrid. One of my column in a datagrid is a template column. In that template column I have used Win forms Textbox and my problem is that,

  1. How to bind that win forms texbox control in WPF?
  2. How to access that control or column in Code behind (c#)?
+1  A: 

You can't use WPF data binding with WinForms controls, WPF data binding requires dependency properties and FrameworkElement derived objects - both are part of WPF and not available in WinForms.

WinForms has it's own data binding system, it's completely incompatible with WPF's data binding (it's also weaker and unusable in some cases).

If you want to use WPF's databinding you have to use only WPF controls.

I suggest you either use the WPF TextBox or switch the entire grid to WinForms and use DataGridView.

by the way - I wouldn't put a WinForms control inside a WPF data grid (or any other items control) - I suspect this will give you a lot of trouble in the future.

Nir