I want to make a window with my own shape. Without a button on taskbar. And when press ALT+F4 it just minimize.
How to make a minimize effect when close window
Forgive my bad English.
I want to make a window with my own shape. Without a button on taskbar. And when press ALT+F4 it just minimize.
How to make a minimize effect when close window
Forgive my bad English.
You can create a non-rectangular window by using the Window.AllowsTransparency property. This sample (http://msdn2.microsoft.com/en-us/library/aa358516.aspx) shows you how.
Setting Window.ShowInTaskbar=false will remove window button from the taskbar.
To minimize the window when pressing Alt+F4, attach Window.Closing event, and inside the event handler, first cancel closing by setting CancelEventArgs.Cancel=true, then set WindowState=Minimized.
Hope this answers your question.
Thanks.
Kasyan,
I followed Eddie's instructions and was able to have a non-rectangular window minimize, be hidden, and not have a task bar button.
Any chance you could post the relevant bits of your window's markup and code-behind
Also, once the window disappears, how does it reappear again
My code
<
Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" x:Class="WindowsApplication1.Window1" Title="WindowsApplication1" Height="300" Width="300" ShowInTaskbar="False" Closing="Window_Closing" AllowsTransparency="True" WindowStyle="None">
<
Grid></< FONT>Grid>
</< FONT>Window>
using
System;using
System.Collections.Generic;using
System.Text;using
System.Windows;using
System.Windows.Controls;using
System.Windows.Data;using
System.Windows.Documents;using
System.Windows.Input;using
System.Windows.Media;using
System.Windows.Media.Imaging;using
System.Windows.Shapes;using
System.ComponentModel;
namespace
WindowsApplication1{
/// <summary> /// Interaction logic for Window1.xaml /// </summary> public partial class Window1 : System.Windows.Window{
public Window1(){
InitializeComponent();
}
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e){
e.Cancel =
true; this.WindowState = WindowState.Minimized;}
}
}
I hope you can help me.
I ran your code, but I see the behavior that it sounds like you are trying to build.
Can you describe your requirements in more detail
I want to create a window without a system buttons and without a border.
-- use windowstyle=None and set borderthickness=0
I want to create a window with own shape and own buttons for close and minimize window.
-- use allowstransparency=true and background=transparent
I want that my window has not a button in taskbar, but has a notifyicon.
-- listen to the windowstatechanged event and when the state is minimized call window.hide()
You would also have to use the winforms NotifyIcon class to have the notifiy icon in the systray
When a press close button or ALT+F4 my window must minimize, i.e. just disappear from desktop.
-- you can listen to the previewInput event and on alt+f4 set the state to minimize.. this will trigger the 3rd requirement