The problem is that when you create your
id
instance in the Click handler, it a local variable that holds it:
private void Button_Click(object sender, RoutedEventArgs e)
{
id IDOBJE = new id();
...
}
So at the end of the method, it's thrown away - as are all local variables.
Worse, you then close the form!
Instead of trying to create a new instance, use the current one, and create a property in your form which allows the outside world to access it.
public class id
{
public string Name { get; set; }
}
...
public id Id { get; private set; } = new id();
private void Button_Click(object sender, EventArgs e)
{
Id.Name = txtshenimi.Text;
this.Close();
}
Then when your form closes, the calling code - assuming it used ShowDialog to display the form - can access the
id
as necessary.