How to prevent closing browser window?

Another implementation is the following you can find it in this webpage: http://ujap.de/index.php/view/JavascriptCloseHook <html> <head> <script type=”text/javascript”> var hook = true; window.onbeforeunload = function() { if (hook) { return “Did you save your stuff?” } } function unhook() { hook=false; } </script> </head> <body> <!– this will ask for confirmation: –> <a href=”http://google.com”>external link</a> <!– … Read more

How to set the location of WPF window to the bottom right corner of desktop?

This code works for me in WPF both with Display 100% and 125% private void Window_Loaded(object sender, RoutedEventArgs e) { var desktopWorkingArea = System.Windows.SystemParameters.WorkArea; this.Left = desktopWorkingArea.Right – this.Width; this.Top = desktopWorkingArea.Bottom – this.Height; } In brief I use System.Windows.SystemParameters.WorkArea instead of System.Windows.Forms.Screen.PrimaryScreen.WorkingArea

No creation of a WPF window in a DLL project?

Make sure the project type is WPF User Control Library when you create your project. If it isn’t then no sweat, just edit the csproj file and make sure the <ProjectTypeGuids> element under Project/PropertyGroup contain the following GUIDs <ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> Also, make sure you reference PresentationFramework and System.Xaml in your project, or you will not get … Read more

How to make title bar disappear in WPF window?

You need to set the WindowStyle property to None, like I outlined in this answer <Window … WindowStyle=”None” WindowState=”Maximized” WindowStartupLocation=”CenterScreen”> You can also set AllowsTransparency=”True” and Background=”Transparent” if you wish to hide the entire window frame and build your own. Update based on code added to question The code you just posted works fine for … Read more

Refer to active Window in WPF?

One possible way would be to scan the list of open windows in the application and check which one of them has IsActive = true: Application.Current.Windows.OfType<Window>().SingleOrDefault(x => x.IsActive); Not sure if there may be more than one active window if, for example, there’s a modal dialog showing, in which case, the owner of the dialog … Read more

What’s the difference between the Window.Loaded and Window.ContentRendered events

I think there is little difference between the two events. To understand this, I created a simple example to manipulation: XAML <Window x:Class=”LoadedAndContentRendered.MainWindow” xmlns=”http://schemas.microsoft.com/winfx/2006/xaml/presentation” xmlns:x=”http://schemas.microsoft.com/winfx/2006/xaml” Name=”MyWindow” Title=”MainWindow” Height=”1000″ Width=”525″ WindowStartupLocation=”CenterScreen” ContentRendered=”Window_ContentRendered” Loaded=”Window_Loaded”> <Grid Name=”RootGrid”> </Grid> </Window> Code behind private void Window_ContentRendered(object sender, EventArgs e) { MessageBox.Show(“ContentRendered”); } private void Window_Loaded(object sender, RoutedEventArgs e) { MessageBox.Show(“Loaded”); … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)