Background: I have a project which use the datagrid to display the data, and the datagrid has a rowdetail column which include a usercontrol. The usercontrol has some TextBo
You can use the Popup
control. Attach a Popup
to the current row of your datagrid, probably when you click the button is a good place to create the popup and place it as a child of one of cells in the row you are in.
Then you can add the usercontrol to the popup and then 'show' the popup. This way, the DataContext for the popup and thus for the usercontrol is inherited from the containing row in the datagrid.
Below is a very simple implementation of a Popup
control just using XAML:
The popup is included in the stackpanel, but is only visible, IsOpen
, when the checkbox is checked. You would place your usercontrol in the popup, where I have put the border and textblock.
Since the popup is a member of the stackpanel, it automatically uses the DataContext of the stackpanel if it does not have one of its own.
In your instance the stackpanel I am showing would be analogous to your DataGrid row.