Question

I have a list like this on my home page on my WPF (C#) project like this:

var sintomas = new List<string>();

I need to add data to that list through different pages from some Radio Buttons so I can set for example in my second page:

if(RadioButton.isChecked)
sintomas.Add("Something");

What do I have to do to initialize it and then use it on each page?

Same for variables.

Was it helpful?

Solution

I think you need to do

Public static List<string>() sintomas = new List<string>();

Then in your other class:

private YourClass Yourname = new YourClass();

Then you could acces the list like this:

Yourname.sintomas.add("yay");

Update

On the start of your class so after:

public partial class AddisHome : Window
{

You need to create your list like this:

   Public List<string> sintomas = new List<string>();

It's public so other classes can acces it

Then on your second class:

again on the top of your other class after:

    public partial class Personaldata : Window
    {

You need to add this:

private AddisHome yourvar = new AddisHome();

then inside your function you can call:

yourvar.sintomas.add("yay");
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top