Closing a window in WPF

You only need to input this.Close(); before showing next window. private void Button_Click_1(object sender, RoutedEventArgs e) { Window2 win3 = new Window2(); this.Close(); win3.Show(); }

Assist me to define UI in xaml [closed]

The first thing is: It is in 99% of all cases the best and possible to write you UI in XAML. Second you should inform yourself, whats the WPF indicates and how to use the MVVM. If you don’t you should stay by Windows Forms! So now: You ViewModel: using System; using System.Collections.Generic; using System.Collections.ObjectModel; … Read more

Saving values from arraylist to txt C# [closed]

static void SaveArray() { ArrayList myArray = new ArrayList(); myArray.Add(“First”); myArray.Add(“Second”); myArray.Add(“Third”); myArray.Add(“and more”); StreamWriter sw= File.CreateText(@”C:\file.txt”); foreach (string item in myArray) { sw.WriteLine(item); } sw.Close(); } and you shouldn’t use arraylist not because its 2013 ,but because arraylist boxing each item in the array, where List store the type also. this cost less in … Read more

WPF Shaped Button – Visaul Studio/Blend

You need to create a ControlTemplate for the Button. This can be done both in Blend and Visual Studio. I did it in VS2015. Here is your code: But, for the future, try to do some work yourself before posting the question. Include just enough code to allow others to reproduce the problem. For help … Read more

Login Form in C# windows Presentation Foundation

Closing the MainWindow will kill the application, as it stores the main thread (main method), instead of this.Close(); use this.Hide(); and your code should work assuming your database connection is correct. Anyway here is a very very quick example I wrote in WPF to help you understand passing parameters from one window to another correctly.

How to get ToolTip from WPF Data Grid Column Header (DataGridTemplateColumn) in code?

Put the TextBlock in the HeaderTemplate of the column: <DataGridTemplateColumn x:Name=”col”> <DataGridTemplateColumn.HeaderTemplate> <DataTemplate> <TextBlock Text=”Current” ToolTip=”Price” ToolTipService.InitialShowDelay=”0″ ToolTipService.Placement=”Top” ToolTipService.ShowDuration=”999999″ RenderOptions.BitmapScalingMode=”NearestNeighbor”/> </DataTemplate> </DataGridTemplateColumn.HeaderTemplate> </DataGridTemplateColumn> …and find it in using the VisualTreeHelper: private void Button_Click(object sender, RoutedEventArgs e) { var columns = FindVisualChildren<System.Windows.Controls.Primitives.DataGridColumnHeader>(dataGrid)? .ToArray(); if (columns != null) { int columnIndex = 1; if (columns.Length > columnIndex) … Read more

Path separators are missing

The issue is that your FileName has single slashes in it. JS will interpret those slashes as escape characters. The simplest solution is to replace your single slashes with double slashes: _mainWindow.Browser.ExecuteScriptAsync( “document.getElementById(‘location’).value=” + ‘\” + openFileDialog.FileName.Replace(@”\”, @”\\”) + ‘\”);

.NET bug. How to fix?

I solved this problem by using the Dispatcher: private void grid_SizeChanged(object sender, SizeChangedEventArgs e) { //text.Text = grid.Width.ToString(); Dispatcher.BeginInvoke(new Action(() => text.Text = grid.Width.ToString())); } Thank you all for “help” and negative rating.