Getting Started-
Assembling a Free WPF Development Toolset

Want to get started playing around with WPF applications, but you'd rather save your cash for some SLI video cards? Never fear - we've assembled a list of free (as in gratis) tools for most facets of WPF development.

Essentials

Visual Studio Express Editions (C#/VB.NET)  and Visual Studio Extensions for .NET 3.0  will get you up and running and building "hello world".

Optional - Development

Microsoft Windows Software Development Kit for Windows Vista and .NET Framework 3.0 Runtime Components - this SDK includes a number of samples, tools and documentation that can be very helpful when developing WPF applications.

Optional - Design

Inkscape is an open-source vector graphics editor. It is ideal for creating vector icons, complex paths, geometries and the like. It's native file format is SVG, an XML dialect for representing vector graphics. In order to incorporate Inkscape into your WPF tool-chain you'll need this handy SVG to XAML converter, written by Andrej Benedik from wpf-graphics.com.

Optional - 3D

Blender is the free open source 3D content creation suite. You can use it to develop 3D content, which you then export to XAML using this export script from Daniel Lehenbauer from the WPF 3D team at MS. Note - the latest release of Blender seems to have some issues running on Vista. Also, to run the export script you will need to install Python.

Optional - Components

Xceed DataGrid for WPF is a free, commercial-quality data grid offered by Xceed. WPF does not include a datagrid as one of the build-in controls, and Xceed has more than filled this gap with their grid. You can also catch an interview with Pascal Bourque, one of the senior developers from Xceed on Channel9, talking about the new approaches and opportunities for developing components for WPF.

posted on 7/6/2007 3:41:19 AM ( 47 Comments )


How To-
Adding Simeltaneous Video Recording + Playback to WPFMediaKit's VideoCaptureElement

When it comes to awesome WPF + DirectX video hacks it's Jeremiah Morrill's world, we're just living in it. One of his great contributions to the WPF ecosystem is the WPF Media Kit which adds DVD playback, webcam playback and a number of other capabilities to WPF. One slight deficiency with the webcam control (VideoCaptureElement) is that it doesn't allow simeltaneous recording and display of webcam content....until now!

This code adds simeltaneous video playback and capture to the VideoCaptureElement. VideoCaptureElement gets a "OutputFileName" property which is used to specify where the webcam output will be saved. If this property isn't set then the control functions as before, just showing webcam playback. Most of the changes are in VideoCapturePlayer (VideoCaptureElement is really only a WPF-ized wrapper around VideoCapturePlayer). I've left a copy of the un-modified version of VideoCapturePlayer.cs in the same directory (called VideoCapturePlayer_old.cs) for those who want to look at the differences for themselves, but the main part is where we check to see if the fileName field has been set and if so set up the relevant properties. 

IBaseFilter mux = null;
IFileSinkFilter sink = null;
if (!string.IsNullOrEmpty(this.fileName))
{
    hr = graphBuilder.SetOutputFileName(MediaSubType.Asf, this.fileName, out mux, out sink);
    DsError.ThrowExceptionForHR(hr);

    hr = graphBuilder.RenderStream(PinCategory.Capture, MediaType.Video, m_captureDevice, null, mux);
    DsError.ThrowExceptionForHR(hr);

    // use the first audio device
    var audioDevices = DsDevice.GetDevicesOfCat(FilterCategory.AudioInputDevice);

    if (audioDevices.Length > 0)
    {
        var audioDevice = AddFilterByDevicePath(m_graph,
                                            FilterCategory.AudioInputDevice,
                                            audioDevices[0].DevicePath);

        hr = graphBuilder.RenderStream(PinCategory.Capture, MediaType.Audio, audioDevice, null, mux);
        DsError.ThrowExceptionForHR(hr);
    }
}

hr = graphBuilder.RenderStream(PinCategory.Preview,
                               MediaType.Video,
                               m_captureDevice,
                               null,
                               m_renderer);

The last call to RenderStream() uses a PinCategory of Preview which allows the display of video, the previous calls to RenderStream() were using the Capture pin category, which causes the media to be written to disk. I've updated the sample application that accompanies WPFMediaKit to default to the "webcam sample" screen, and to save the webcam output as a randomly named .wmv file to the "my documents" folder. 

This code is very much proof-of-concept, and I'm concerned about leaks in there, but it does work. One limitation is that the file name can't be set after the graph has been set up, but this seems to be a common limitation with properties on the capture device - to change them you have to re-create the graph.

In any case I hope you find this code useful, and I'll be offering it up to Jeremiah for consideration as a patch to WPFMediaKit.

posted on 1/9/2010 11:46:42 PM ( 3 Comments )

Free Embeddable Fonts for your WPF Applications

Using attractive typefaces can add individuality to your application, or reinforce your brand. Although we talked about the means to embed WPF fonts in your application a long time ago, the biggest issue with font embedding is the licensing issues associated with fonts, especially if you’re working on a code sample or free utility. Most fonts, even the multitude that you can download for free online, are not licensed to allow redistribution as part of your application.

Fortunately a small group of fonts has started to be released under a much more permissive license – the SIL Open Font License (OFL) - which specifically allows embedding in applications, both commercial, free and open-source (disclaimer: I am not a lawyer, you should read the license yourself and/or seek legal advice before making any decisions regarding font licensing). This is a very generous move on the part of these type designers who spend considerable time and skill on designing beautiful fonts.

Here is a sample application that uses some of my favourite of OFL-licensed fonts from around the web including Titillium, Goudy Bookletter 1911, and Junction. Great resources for finding new fonts with the OFL license is the Open Font Library and the League of Movable Type.

download source [413 KB] (including fonts!)

From a programming point-of-view it pays to remember this trick from the MSDN for finding the names of embedded fonts. Sometimes the name is not apparent from the file name OR from the info you see in the "Install Font" dialog in windows. Instead you can programatically iterate through the installed fonts using this snippet of code.

// iterates over embedded fonts - assumes you have fonts in a sub-directory called "Fonts" in the project in visual studio
foreach (var fontFamily in Fonts.GetFontFamilies(new Uri("pack://application:,,,/"), "./Fonts/"))
{
    // do stuff with fonts here
}

posted on 11/23/2009 10:24:01 PM ( 49 Comments )

.NET Framework 4.0 Solves the Single Biggest Problem with WPF Development

.NET Framework 4.0 solves the single biggest problem with WPF development - The size of the .NET framework redistributable. The full redistributable for the x86 version of the .NET framework weighs in at a svelte 37.71 MB, and the cut-down client profile (that should be suitable for many WPF client applications) is just under 31 MB! For 64-bit platforms (x64 and ia64) the full redistributable are about 55 MB each. They both have the x86 bits included also so x86 .NET applications can run in the WoW. You can get all the details here (including what is in and out of the client profile, how to target etc here). Compared to the 230 MB for the full redistributable for .NET Framework 3.5 sp1 this is a welcome relief. Whatever techniques the .NET framework team have learned putting silverlight on an extreme diet have paid off here too. Lets hope this minification of the framework continues into the RTM version.

posted on 10/21/2009 10:09:58 PM ( 46 Comments )

The Visual Guide to WPF Font Weights

Have you ever wondered what the difference between DemiBold and SemiBold text is? (the answer: not a whole lot). Have you ever wanted to go beyond "Normal" and "Bold" in your font weight selections? If so then this post is for you.

The following shows the different font weights (both names and numeric values) for the default UI font in Windows 7 and Windows Vista - Segoe UI at 24pt.

Segoe UI Font Weights

We can immediately see that Segoe UI supports a variety of weights, but why does 'Thin' (supposedly at 100-weight) look the same as 'Light' (300-weight)? The answer is the font itself - it only supports 4 different weights. Switching to Calibri we can see that it contains only two different weights.

Calibri Font Weights

The moral of the story is that WPF provides great typographic support for different font weights, but not all fonts will support all weights. Here is the XAML code to play around with different font families.

<Page
  xmlns="
http://schemas.microsoft.com/winfx/2006/xaml/presentation "
  xmlns:x="
http://schemas.microsoft.com/winfx/2006/xaml ">
  <Page.Resources>
    <Style TargetType="{x:Type TextBlock}">
      <Setter Property="FontFamily" Value="Calibri" />
      <Setter Property="Margin" Value="5" />
      <Setter Property="FontSize" Value="24" />
    </Style>
  </Page.Resources>
  <StackPanel >
<TextBlock FontWeight="Thin"  Text="Jackdaws love my big sphinx of quartz - Thin - 100" />
<TextBlock FontWeight="UltraLight"  Text="Jackdaws love my big sphinx of quartz - UltraLight - 200" />
<TextBlock FontWeight="ExtraLight"  Text="Jackdaws love my big sphinx of quartz - ExtraLight - 200" />
<TextBlock FontWeight="Light"  Text="Jackdaws love my big sphinx of quartz - Light - 300" />
<TextBlock FontWeight="Normal"  Text="Jackdaws love my big sphinx of quartz - Normal - 400" />
<TextBlock FontWeight="Regular"  Text="Jackdaws love my big sphinx of quartz - Regular - 400" />
<TextBlock FontWeight="Medium"  Text="Jackdaws love my big sphinx of quartz - Medium - 500" />
<TextBlock FontWeight="DemiBold"  Text="Jackdaws love my big sphinx of quartz - DemiBold - 600" />
<TextBlock FontWeight="SemiBold"  Text="Jackdaws love my big sphinx of quartz - SemiBold - 600" />
<TextBlock FontWeight="Bold"  Text="Jackdaws love my big sphinx of quartz - Bold - 700" />
<TextBlock FontWeight="UltraBold"  Text="Jackdaws love my big sphinx of quartz - UltraBold - 800" />
<TextBlock FontWeight="ExtraBold"  Text="Jackdaws love my big sphinx of quartz - ExtraBold - 800" />
<TextBlock FontWeight="Heavy"  Text="Jackdaws love my big sphinx of quartz - Heavy - 900" />
<TextBlock FontWeight="Black"  Text="Jackdaws love my big sphinx of quartz - Black - 900" />
<TextBlock FontWeight="ExtraBlack"  Text="Jackdaws love my big sphinx of quartz - ExtraBlack - 950" />
<TextBlock FontWeight="UltraBlack"  Text="Jackdaws love my big sphinx of quartz - UltraBlack - 950" />
  </StackPanel>
</Page>

posted on 10/6/2009 11:29:33 PM ( 32 Comments )

Round Gel-like button template for WPF

I keep re-creating this from time to time, so I thought I would put it up for others to use. This is a very simple style for rounded gel-like buttons (shown here magnified 3x, but the style works OK for buttons of various sizes). The left-most one is the "normal" style, the middle one is mouse-over and focused, and the right one is disabled. These are great with a slider to create "zoom" type controls, or for play/pause buttons etc.

Source Xaml

posted on 4/27/2009 10:08:00 PM ( 41 Comments )


WPF Community-
TODO: aggregation of WPF sites goes here