There is a simple class, I can not understand why I can not refer to the previously created object?
public partial class MainWindow : Window { public MyRepository MainRepo; public MainWindow() { MyRepository MainRepo = new MyRepository(); InitializeComponent(); DataContext = MainRepo; } private void AddMyButton_Click(object sender, RoutedEventArgs e) { .... MainRepo.AddMy(TempMy); } Why is MainRepo in the click handler null? When a program is started with tracing, it gets into the MainWindow method, the MainRepo object is created
MainRepoare created, one public in the class and the other local in theMainWindowconstructor. - Gennady P