Search code examples
c#wpfdata-exchange

data exchange of two windows WPF


I´m actually programming a WPF-application. Now, I´m just a beginner in WPF and so I´ve a problem:

In window A, there is a checkbox with some values. If I click on a button on window A, window B should open. On window B, I have a textfield and a save-button. When I click on the button on window B and close it, the value of the textfield should be in the checkbox on window A.

First, I programmed this with Windows Forms and there I solved it with BindingSource. This doesn´t work in WPF. How can I solve that?


Solution

  • Well, I would say that this nothign to do with WPF ot WindowsForms, as idea can be applied in both places. Just use a shared between different forms DataStructure that holds and information you need and changed from different forms. Just to give a simple idea:

    public class DataStructure 
    {
       //properties 
    }
    
    public Form1 : Form 
    {
        public Form1(DataStructure ds) {}
    }
    
    
    
    public Form2 : Form 
    {
        public Form2(DataStructure ds) {}
    }