Expression > Forums Home > Related Technologies Forums > Windows Presentation Foundation (WPF) > what is the best practice in wpf to create a custom window?
Ask a questionAsk a question
 

Answerwhat is the best practice in wpf to create a custom window?

  • Sunday, April 19, 2009 7:46 AMLisa Tatum Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hello,

    is the best practice in wpf making a custom window by changing the ControlTemplate of the Window?

    On the other side I could also make the Window with transparent background+no titlebar visible put a border element in it and format this border with rounded edges and colorize this one. So every effect I put on the border which is in the client area now it renders fast + hardware accelerated RIGHT? Putting effects directly on the window control would make it software rendering RIGHT?

Answers

All Replies

  • Sunday, April 19, 2009 2:41 PMYiling LaiMVPUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Hi

    No, All the WPF bitmap effect are rendered with software mode in .NET 3.0. Any object that applies an effect will also be rendered in software. So I think the best way of make rounded corner custom window is define it's ControlTemplate, but don't set border corner, I'd prefer to use P/Invoke use API SetWindowRgn to make rounded corner for best performance in current WPF.

    http://blogs.msdn.com/wpfsdk/archive/2008/09/08/custom-window-chrome-in-wpf.aspx
    Yiling, MVP(Visual C++)
    • Marked As Answer byTao Liang Tuesday, April 21, 2009 2:14 AM
    •  
  • Sunday, April 19, 2009 7:33 PMLisa Tatum Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hi

    No, All the WPF bitmap effect are rendered with software mode in .NET 3.0. Any object that applies an effect will also be rendered in software. So I think the best way of make rounded corner custom window is define it's ControlTemplate, but don't set border corner, I'd prefer to use P/Invoke use API SetWindowRgn to make rounded corner for best performance in current WPF.

    http://blogs.msdn.com/wpfsdk/archive/2008/09/08/custom-window-chrome-in-wpf.aspx
    Yiling, MVP(Visual C++)
    using the winapi partly like P/Invoke will this Window also run under vista + windows 7 ? or do I have to fear compatibility problems?
  • Monday, April 20, 2009 5:39 AMYiling LaiMVPUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Yes, It's compatible.
    Yiling, MVP(Visual C++)
  • Saturday, November 07, 2009 2:43 PMjulian ustiyanovych Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hi Folks,

    After my first experience, following "magic combination " is really VERY Buggy in WPF: (AllowsTransparency="True") + (Combobox) = dropdown list appears behind the form.

    As Microsoft  guys mentioned: this issue might be related to the Win32k.sys driver displays the order of layered windows incorrectly.

    This is a known BUG, that Microsoft published on the official website.

    They have also created HotFix package that helps to avoid this BUG. Buuuuut....

    A supported hotfix you could download from here: http://support.microsoft.com/kb/943326

    I'd like to see an example how to use "P/Invoke SetWindowRgn" to create custom windows.

    I'll be very-very-very thankful if anyone could post some code snippet.

    thnak you in advance,

    Julian