Posts

  • Custom Window Control - GlassWindow - Source Code

    Sometime back I had posted about the Custom Window Control but was a little lazy in putting up the source code as it was part of a bigger library. I have finally taken it out, changed the namespaces and removed some dependencies. Feel free to use the code as you wish. If you add any extra cool stuff, I would love to hear back :) The zip contains the GlassWindow control with the Vista and the MacOSX window templates.

    Continue reading...

  • Reusing decorative panels with ContentControl + ControlTemplate

    Of late I found a new use for ContentControl, which is to use it as a decorator (note the small-case ’d’). Lets take an example to illustrate this idea. Imagine you want to use a panel decoration like the one below:

    image

    Continue reading...

  • Mixing 2D and 3D

    Greg Schecter from the WPF/DWM team has made an interesting post about overlaying 3D content over 2D elements. This is to transition between different states of the UI by using 3D effects.

    Continue reading...

  • Creating and consuming XAML icons from Expression Design

    I really like the simplicity and ease of use in Expression Design. Vector editing never felt so enjoyable. I play the dual role of designer and developer for my projects – not always good, but works for now. Recently I had to create some simple icons in Design and use them in a WPF app. The workflow I adopted simplified the process and made it easier for me to use. I’ll outline the steps I adopted below.

    Continue reading...

  • The new Expression Blend RC

    The Blend RC has just been released. As an eager child I got hold of it and checked if my projects were looking good inside it!

    Continue reading...

  • Creating an ObjectDataProvider using CLR properties

    OK I agree that the title of this post doesn’t convey anything meaningful about the post ;) But the post itself is pretty useful, trust me.

    I am sure most of you have heard and used the ObjectDataProvider (extensively). ObjectDataProvider (ODP) acts as a wrapper around your CLR object and helps in the data-binding. There are couple of ways of creating the ObjectDataProvider. Beatriz Costa did a great post on this topic, so I am not going over those details. Interestingly there is one more way of creating the ObjectDataProvider, which is just an extension of using the MethodName property.

    Continue reading...

  • Balloon Text - using Decorators

    image

    Recently I had to render some text inside a Balloon, similar to the balloons that you see in Comic Strips. They are also called Speech Balloons.

    image

    Continue reading...

  • Attached events

    We are all well aware of the Attached properties concept and have definitely used it a lot. But on a similar tone there is also the concept of Attached Events, which are useful in some particular cases.

    Imagine you have a set of Buttons contained inside a WrapPanel.

    1<WrapPanel Button.Click="CommonHandler">
    2    <Button x:Name="btn1"
    3                    Content="Click me"/>
    4    <Button x:Name="btn2"
    5                    Content="Click me"/>
    6    <Button x:Name="btn3"
    7                    Content="Click me"/>
    8    <TextBlock x:Name="_statusText"/>
    9</WrapPanel>

    Continue reading...

  • Grava for Educational content

    Just saw this post on Rob Relyea’s blog about Grava, a new WPF based toolset for creating Educational content. The screenshots look exciting. It has an SDK and a bunch of other stuff. Should be a great tool to play with…and learn! Grava Website
  • Instantiating a custom object-tree in XAML

    XAML, which is short for eXtensible Application Markup Language is a great tool for instantiating objects, not just WPF ones. Although I was aware of this feature for a long time, I never got around to using it exclusively. Recently in one of my projects I wanted to instantiate a simple Object tree, which has WorflowTypes.Workflow as the root type and a property called Screens that stores objects of type WorflowTypes.Screen. I had to create this structure at my application-startup and I was originally doing it by hand. Instead representing that structure in Xaml appeared to be far more convenient.

    Continue reading...

  • Baml Disassembler for Reflector

    We all know how useful Reflector is! Now it has added a cool new ability to disassemble BAML files! …you know those compiled XAML files. I saw this post on UrbanPotato.net that tells you how to get it running on your machine.

    Continue reading...

  • Neon - The WPF Particle Engine

    The WPF animation system is very powerful and at the same time also very easy to program. For most animations Storyboards should suffice but for some scenarios you may have to resort to using Frame-based animations. Ideally I would want to fit all animations into a Storyboard, in one form or the other. However that may not be feasible all the time. Take the case of particle effects like fire, snow, bubbles, smoke etc. Creating these effects is fun but not always easy to integrate into a real-world app.

    Continue reading...

  • XamlXporter 0.2 -- exports as Canvas and DrawingBrush

    XamlXporter is a project I undertook (mostly as a pet project) to re-create what Michael Swanson did with his Illustrator Plugin. In other words, XamlXporter allows you to export your Illustrator artwork into WPF/XAML format. The exporter has been written entirely in C#, .Net 2.0 with a WinForms UI. It uses the Adobe Illustrator CS2 COM Type Library to talk to Illustrator. More information can be found on this earlier blog post.

    Continue reading...

  • WPF Multithreading with BackgroundWorker

    UI libraries in general have always been single-threaded. This means that you can access the UI controls only from the thread that created it (thread-affinity). When running long-running operations you would typically use a background thread to do that job. However progress needs to be reported on the UI and the user needs to have a way to cancel the operation. Doing that from a background thread is not possible and hence you have to jump threads, ie. from the background-thread to the ui-thread.

    Continue reading...

  • Custom Animations, the GenieAnimation

    Several weeks back I had posted a simulation of the Genie effect that you see in Mac OSX. Ofcourse it was created using the Windows Presentation Foundation ;) However the effect could only be used in that specific demo. There was no way for example to use it in my other projects, which were also desperately asking for some cool animations. Since then I went through a couple of iterations and made the Genie effect into a reusable animation. This was possible because the WPF animation system makes it pretty easy to create Custom animations. So what I have now is a class called GenieAnimation that can be used directly in XAML.

    Continue reading...

  • Drag & Drop with attached properties - Part 4

    In Part 3 of this series I made some changes which allowed Drag and Drop across Windows and Applications. Although it works well, someone pointed out in the comments to that post, that the drag-point was always at (0,0) even though the user may have clicked somewhere inside the element (ie. not at the [0,0] position).

    Continue reading...

  • Drag & Drop with attached properties - Part 3

    In my previous blog posts (Part 1, Part 2) on this topic, I have discussed how you can add drag-drop behavior to your application using attached properties. This greatly simplifies the event hook-up, keeps the XAML clean and literally gets rid of code-behind. However the previous version did not support the scenario where you are performing DragDrop across windows or across applications. This was pointed out in the comments to my earlier post (Part 2). Well now I am glad to say that even this scenario is supported.

    Continue reading...

  • Custom Window control, the GlassWindow

    Creating custom controls have been greatly simplified in WPF. There are some good practices that people have followed and I have documented some of them here. Although most examples show how to create new UserControls or custom controls derived from existing controls like Button, creating custom Window control was something I wanted in my projects.

    Continue reading...

  • Drag & Drop with attached properties - Part 2

    In my previous post on this topic, I gave a quick overview of how Drag and Drop can be accomplished using attached properties. To review, here are the key elements of the implementation:

    Continue reading...

  • Application.LoadComponent() from un-referenced assemblies

    I recently asked a question in the WPF forums about loading xaml components from unreferenced assemblies, using Application.LoadComponent() API. This is a useful scenario especially if you are developing a plugin architecture for your application. Zhou Yong from the forums replied with a useful tidbit, which I will document in this blog post.

    Continue reading...

  • Drag & Drop with attached properties

    I am a big fan of attached properties and I think it is one of the coolest innovations in WPF. Once you understand the basics of using and creating attached properties, lot of the common activities that typically require some code-behind can be pushed to a class that implements an attached property or a set of attached properties. A good example is the PanelLayoutAnimator from Dan Crevier’s blog.

    Continue reading...

  • Don't forget the AdornerDecorator

    While testing my new Custom Window control (which I should be blogging about soon) I ran into an interesting problem. The custom window control derives from System.Windows.Window and has its own ControlTemplate defined in its generic.xaml file. Now I have an application that makes use of Drag ‘n’ Drop (DnD) and was previously using the regular Window control. When I replaced that with my custom window control, the app would just crash as soon I started dragging some elements. Note that the same DnD code would work with the regular Window control.

    Continue reading...

  • XmlnsDefinition for a cool namespace mapping

    In XAML, when you want to reference a CLR type, you have to add a namespace mapping that maps the XML namespace to the CLR namespace, like so:

    xmlns:local="clr-namespace:MyTestApp.Controls;assembly=TestApp.Controls"

    Continue reading...

  • Initial release of XamlXporter (0.1 alpha)

    As promised I’ve uploaded the source and binaries of XamlXporter. XamlXporter is a script for exporting Illustrator artwork in WPF/XAML. It is written in C# 2.0 for easier maintainence.

    Continue reading...

  • Amazing live Physics simulation program

    Its one of those lucky days when you find a program so cool and that you feel like having it yourself…or if you are developer like, develop it yourself ;) Have a look at this YouTube video (click picture) and you will know what I am talking about.

    Continue reading...