public MainWindow() { _viewModel = new MainWindowViewModel(); _presenter = new MainWindowPresenter(_viewModel); InitializeComponent(); using (var hklm = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64)) using (var key = hklm.OpenSubKey(@"SOFTWARE\Microsoft\Microsoft SQL Server\Instance Names\SQL")) { string[] names = key.GetValueNames(); if (names.Length > 0) { if ("MSSQLSERVER".Equals(names[0], StringComparison.OrdinalIgnoreCase)) { tbServer.Text = "localhost"; } else { tbServer.Text = @"localhost\" + names[0]; } } } Title = App.GetInstanceName(); myGrid.DataContext = _viewModel; }