vish213
vish213

Reputation: 786

Is there a way I can create my own windows of desired shape?

I am trying to learn WPF because I want to create applications with some good visual. I just completed an overview of it but I am not sure if it would serve my purpose. Can someone please direct me in right direction, I have about 1 and half month from now to learn as much about forms and designs as much I can, then I have to start working on my project. Its not related to graphics,but I don't want it to be like others' boring windows forms typo too. Will learning WPF be beneficial? Or just using some third party tools/softwares would be a good choice? Sorry I forgot to mention about title-The biggest thing I want is not to have rectangular windows with usual cross buttons in my project forms. Thankq.

Upvotes: 0

Views: 162

Answers (1)

U1199880
U1199880

Reputation: 905

This is a great tutorial about how to create an irregular shaped Window in WPF: http://buksbaum.us/2009/02/28/irregular-shaped-windows-in-wpf/

Basically, you need to set these properties on the <Window> class:

AllowsTransparency="True"
WindowStyle="None"
Background="Transparent"

then build your window with something like a Border or a Path, then build your own handlers for events such as Closing, Minimizing, and Clicking/Dragging the Window

  private void Window_MouseDown(object sender, MouseButtonEventArgs e)
  {
      if (e.ChangedButton == MouseButton.Left)
          DragMove();
  }

  private void btnExit_Click(object sender, RoutedEventArgs e)
  {
      Close();
  }

  private void btnMinimize_Click(object sender, RoutedEventArgs e)
  {
      WindowState = WindowState.Minimized;
  }

Upvotes: 3

Related Questions