Click here to Skip to main content
Rate this: bad
good
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
good
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">
                          BorderBrush="Transparent"
                          CornerRadius="2"                          
                          HorizontalAlignment="Stretch"
                          Margin="2">
 

behind the popup window u should create a clr property named as SelectedItem .
       private DataRowView _selectedItem;
       public DataRowView SelectedItem
       {
           get
           {
               return _selectedItem;
           }
           set
           {
               _selectedItem = value;
               OnPropertyChanged("SelectedItem");
           }
       }
 
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
  Permalink  
Comments
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 (vasim72@gmail.com)
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 OriginalGriff 383
1 Richard Deeming 180
2 Sergey Alexandrovich Kryukov 171
3 Yogesh Kumar Tyagi 165
4 ChauhanAjay 156
0 Sergey Alexandrovich Kryukov 6,212
1 OriginalGriff 5,498
2 CPallini 2,473
3 Richard MacCutchan 1,627
4 Abhinav S 1,530


Advertise | Privacy | Mobile
Web04 | 2.8.140814.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