I'm starting to study WPF and I have a big doubt
my project WPF has a Books class, which has several attributes, let's say an example
class libros
{
string atributo1;
string atributo2;
string atributo3;
}
question 1 - to create a book type object, that is, to make an instance of this class, where should I do it?
ej > books libro1 = new books ();
When I was working on the console I was doing it in the Main () , but now I do not know where it is, and I do not think it's in MainWindow which is the window that creates defect the program
I have already tried to initialize the objects in MainWindow.xaml of my project wpf , but the "books" objects that I think only the block of < strong> MainWindow as is logical,
If someone could help me with the logic of initialization in WPF or give me a reference of a website that could help me, thank you very much in advance and sorry if I have something wrong in the newsroom.
edited > code
public MainWindow () {
Libros Libro0 = new Libros();
Libro0.Identificador = 000000;
Libro0.Titulo = "La metamorfosis";
Libro0.Autor = "Frank Kafka";
Libro0.Editorial = "Tupe";
Libro0.Materia = "Ficcion";
Libro0.CantidadEjemplares = 5;
Libro0.Estado = true;
label1.Content= Libro0.Autor; //exception nullreference
InitializeComponent();
}