…And another one – a Stocks widget

Here is another attempt at a widget that I put togther in couple of hours last night - this lets you search for Stock quotes. This is fun stuff and easy to do - expect coolers ones from the many talented designers out there once WinFX and Expression Interactive Designer ship!

Two things to note: The OS that the application is being run on is not Windows Vista, it is the Feb. CTP of WinFX on Windows XP - I simply faked out the chrome for the window to look like the Aero glass one. Also, the text box behaves like the ones made popular by AJAX - it shows you a red highlight if the stock symbol that you entered is invalid by querying the Windows Live stock quotes service. If valid, it will show you the name of the company and a green highlight for the text box.

Feel free to download the source, and improve at will (excluding the content) from here. The code and design quality could have been a lot better, but I always run out of time at that point :).

Comments (19)

  1. CHash2 says:

    looks butt ugly

  2. Nice use of the UsesPerPixelOpacity, however I would like to see a sample of using this with NavigationWindow. Any chance of sample that shows that?

  3. Great example. I have a question: does UsesPerPixelOpacity="True" forces software rendering of the content?

  4. Hi Valentin,

    Yes, it does.

    Courtesy Rob Relyea: That is the reason why Popup and HwndSource has this property that you can set on them, but Window does not


  5. Hi Andy,

    Very good question – we should def. be able to make this thing more reusable – with this sample, I only took the first step.

    Another thing we were thinking when reviewing this sample was that it would be cool to write something like XmlHttpRequest made popular by Ajax so web-service queries can be easily processed in async fashion. We will post the results of our investigation…

  6. rabidrobot says:

    I was very excited to see this, but now am a bit confused.  I am new to C# and .NET programming, so keep in mind these questions come from a background of considerable ignorance.

    I do not understand it completely, but the method used to achieve transparency here seems similar to the GadgetUI sample from the SDK.   Is this the only way to have translucent, invisible,  or custom window chrome and content?  

    I get the impression that this is somehow using old tech to make the new tech do what it should do in the first place.  Everything else about a WPF application GUI has numerous ways of altering its opacity (in XAML you can use Visible=, Opacity=, An OpacityMask, Transparency in the vectors graphics, or alter a parent element’s opacity, etc.).  But when it comes to the Window itself things are, apparently, much more complicated.

    I’m not afraid to learn how this works, by any means, but am merely curious if this is, and will continue to be, the recommended method of achieving transparency in WPF desktop applications.

  7. This is a way to fake transparency – I would highly recommend that you don’t do it for a traditional application since this will force WPF to run in s/w rendering mode. I would think this is only practical for widgets and the like. If your goal is to just have not chrome and you are happy with rectangular windows, you can simply set a property on the Window class.

    I totally agree with you – I only wish there was a property on Window class to achieve this effect without writing any code or sub-classing Window. However, because of the s/w rendering gotcha, they don’t have such a property on the Window class.

  8. Corgalore says:

    I was just playing with the code from this sample, converting the application code to vb for the per-pixel opacity. I am having an issue with a window with borders showing up in addition to my window with transparency. Any ideas?

    Also, from what I gather above there will not be any ability to create shaped or semi-transparent applications, hw rendered in this framework? That is a major bummer cause I’ve had so many ideas for how I was going to use that.

  9. lkuech says:

    @ Corgalore: I guess your "Scene1" is still defined as the startup scene, thats the reason you getting the scene twice.

    @all: is there any easy way of making the form movable?

  10. lancelmh says:

    Hi Unnir,

    Very cool, but how to drag this program to move it?

  11. Nitin says:

    why is it not running on my machine. I am getting this exceptions :

    System.IO.IOException was unhandled

     Message="Cannot locate resource ‘scene1.baml’."


  12. Paul says:

    This is for hour the only program (Vystal for Windows 2000/XP) that simulates in way the much similar effect glass of Windows Vista: http://www.mpfweb.info/personalizzare/so.html

  13. Paul says:

    This is for hour the only program (Vystal for Windows 2000/XP) that simulates in way the much similar effect glass of Windows Vista. Direct Link of the constructor for having information:


  14. John Griffin says:

    Any assistance in getting this to drag would be greatly appreciated.

  15. Paul says:

    This is for hour the only program (FastAero for Windows 2000/XP) that simulates in way the much similar effect glass of Windows Vista. Direct Link of the constructor for having information: http://fastaero.wordpress.com/

    It seems better than Vystal

  16. pAUL says:

    TrueTransparency: Fast, simple, for all the PC and cards video.


    For me the best one remains FastAero

  17. Dan says:

    Aren`t You fed up with all those Forex E-books that promise heaven and deliver hell? The "Forex-Killer" is an automated Trading software that does it all! It analyzes the markets and gives you a clear buy or sell order. All you have to do is feed it with the necessary data. A simple 2 minute process !!!…Download The Amazing Software Now:  http://www.urlpire.com/?MALFY

Skip to main content