passing data betwen tabitem and datagrid
-
Hi, i have 2 tabitem, each one cotain a wpf gdatagrid i want to pass data from grid1 in tabitem1 to grid2 in tabintem2 when i click on tab item2 or on boutton. i tried this code but i get exception: L'élément possède déjà un parent logique. Il doit être détaché de l'ancien parent avant d'être attaché au nouveau.
private void btnValidate_Click(object sender, RoutedEventArgs e)
{
for (int j = 0; j < i - 1; j++)
{
TextBlock x = dgrecep.Columns[0].GetCellContent(dgrecep.Items[j]) as TextBlock;// GRID1 TABITEM1
if (x != null)
{
if (v.validate(x.Text))
{dgrecep2.Items.Add(dgrecep.Columns\[0\].GetCellContent(dgrecep.Items\[j\]));//GRID2 TABITEM2 } else { MessageBox.Show("non valide"); }
-
Hi, i have 2 tabitem, each one cotain a wpf gdatagrid i want to pass data from grid1 in tabitem1 to grid2 in tabintem2 when i click on tab item2 or on boutton. i tried this code but i get exception: L'élément possède déjà un parent logique. Il doit être détaché de l'ancien parent avant d'être attaché au nouveau.
private void btnValidate_Click(object sender, RoutedEventArgs e)
{
for (int j = 0; j < i - 1; j++)
{
TextBlock x = dgrecep.Columns[0].GetCellContent(dgrecep.Items[j]) as TextBlock;// GRID1 TABITEM1
if (x != null)
{
if (v.validate(x.Text))
{dgrecep2.Items.Add(dgrecep.Columns\[0\].GetCellContent(dgrecep.Items\[j\]));//GRID2 TABITEM2 } else { MessageBox.Show("non valide"); }
Why on earth are you doing this via code behind? You really need to read up on MVVM, and judging by the number of questions you have posted in this forum, I would suggest that you need to read a basic book on WPF, such as Adam Nathan's excellent WPF Unleashed.
*pre-emptive celebratory nipple tassle jiggle* - Sean Ewington
"Mind bleach! Send me mind bleach!" - Nagy Vilmos
CodeStash - Online Snippet Management | My blog | MoXAML PowerToys | Mole 2010 - debugging made easier
-
Why on earth are you doing this via code behind? You really need to read up on MVVM, and judging by the number of questions you have posted in this forum, I would suggest that you need to read a basic book on WPF, such as Adam Nathan's excellent WPF Unleashed.
*pre-emptive celebratory nipple tassle jiggle* - Sean Ewington
"Mind bleach! Send me mind bleach!" - Nagy Vilmos
CodeStash - Online Snippet Management | My blog | MoXAML PowerToys | Mole 2010 - debugging made easier
I am a student and I'm doing my final year project and this project is the first work with WPF, I downloaded a book and I make every effort to learn because I believe in that "le difficile c'est le chemin" and I asked a lot of questions because I have a month to develop my application also it is not MVVM because company demanded another architecture...thank you
-
I am a student and I'm doing my final year project and this project is the first work with WPF, I downloaded a book and I make every effort to learn because I believe in that "le difficile c'est le chemin" and I asked a lot of questions because I have a month to develop my application also it is not MVVM because company demanded another architecture...thank you
I find it hard to believe that a company would demand no architecture whatsoever. What you are doing is code behind and is not suited to solving the problem you are trying to solve. Now is the time for you to embrace the right way to do it.
*pre-emptive celebratory nipple tassle jiggle* - Sean Ewington
"Mind bleach! Send me mind bleach!" - Nagy Vilmos
CodeStash - Online Snippet Management | My blog | MoXAML PowerToys | Mole 2010 - debugging made easier