Click here to Skip to main content
Rate this: bad
Please Sign up or sign in to vote.
See more: C# WPF
I currently have a DataGrid which is populated by a list using DataGrid.DataContext = list
My issue is that i need to edit these values in a seperate WPF window. I've read many articles about in-line editing, but not much on populating the table from another window.
The edit window will have OK and Cancel buttons, and should only mirror the changes back to the datagrid on the OK command. The secondary window should also be populated with the selected row's values. Can provide code so far if necessary.
Posted 25-Sep-12 0:39am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

i hope your main window contain DataGrid .
create a datatemplate
<datatemplate x:key="DataTemplateBaseChargeSetting" xmlns:x="#unknown">
                <border borderthickness="1">

behind the popup window u should create a clr property named as SelectedItem .
       private DataRowView _selectedItem;
       public DataRowView SelectedItem
               return _selectedItem;
               _selectedItem = value;
on edit button click event
call pop window
and create object of pop window and call their property and assign the selected row to that property
Member 9454261 at 25-Sep-12 8:36am
The data template didn't seem to compile too well - am i right in thinking that just goes in MainWindow.xaml?
vasim sajad at 25-Sep-12 8:45am
datattemplate should be place in xaml file not in xaml.cs file
it cant be compile
Member 9454261 at 25-Sep-12 12:04pm
Sorry when i say compile, i mean there were many errors in Visual Studio.
vasim sajad at 26-Sep-12 0:07am
can u post ur code ? or mail me those code (
Member 9454261 at 27-Sep-12 9:32am
emailed the code

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 531
1 OriginalGriff 334
2 DamithSL 235
3 Maciej Los 170
4 Bruno Sprecher 130
0 DamithSL 95
1 OriginalGriff 65
2 Gopu Raj 30
3 Mahsa Hassankashi 25
4 Raul Iloc 25

Advertise | Privacy | Mobile
Web02 | 2.8.141030.1 | Last Updated 25 Sep 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100