Click here to Skip to main content
13,350,861 members (65,441 online)
Click here to Skip to main content
Add your own
alternative version


262 bookmarked
Posted 11 Nov 2006


, 13 Jul 2008
Rate this:
Please Sign up or sign in to vote.
A free library of controls and utility classes for use in WPF applications.



Welcome to WPF.JoshSmith. This is not a typical CodeProject article. I am using the Web page generated for this article to host, and make publicly available, a library of classes I have created for use in Windows Presentation Foundation applications. Over time I will update this page (and the source code download) to include any new classes I've added to the WPF.JoshSmith library. Think of this as a really cheap and easy alternative to creating a full Web site just to make the assembly available to the world.

All of the major classes in WPF.JoshSmith either have an article about them here on the CodeProject, or I've blogged about them. The purpose of WPF.JoshSmith is to consolidate all of the classes I've created into one place, thus making it easier for people to have all the goodies in one assembly. In addition to providing the WPF.JoshSmith assembly, the source code download at the top of this article also contains test/demo projects for many of the various classes in the library. Those projects show how to use the code and what the various classes do.

All of the code in the library can be used free of charge, provided that the copyright statements in each source file remain intact. Josh Smith accepts no responsibility for any errors, loss of data, system crashes, etc. that occur as a result of using WPF.JoshSmith.


This section provides an overview of the major classes available in the library, divided up by namespaces. Click on the name of a class to open an article/blog entry which discusses it in depth.

  • WPF.JoshSmith
    • Adorners
      • DragAdorner - A lightweight adorner which renders a visual that can follow the mouse cursor, such as during a drag-and-drop operation. Original concept taken from this blog post.
      • UIElementAdorner - An adorner which can display one and only one UIElement. The element is added to the adorner's visual and logical trees, enabling it to particpate in dependency property value inheritance, amongst other things.
    • Controls
      • Validation
        • RegexValidationRule - A ValidationRule-derived class which supports the use of regular expressions for validation.
        • RegexValidator - A static class which provides attached properties that supply validation of the text in a TextBox, using regular expressions. This class works in conjunction with the RegexValidationRule.
      • CenteredContentControl - A ContentControl derivative which exposes read-only dependency properties that return the element's center point (CenterX and CenterY). Those values can be used to bind another element (such as a Line) to the center of the CenteredContentControl, even if it is relocated at runtime.
      • RoutedDataTemplateSelector - A DataTemplateSelector that bubbles a routed event when asked for a template, allowing an element in the visual tree to decide what template to use.
      • SlidingListBox - A ListBox which provides an animated slide effect when ListBoxItems are selected.
      • SmartTextBox - A TextBox with support for displaying a list of suggestions when the user misspells a word. The user presses the F1 key to display the list of suggestions.
    • Data
      • ValueConverters
        • EnumValueToDescriptionConverter - An IValueConverter which supports conversion from an enum value to the description of that value. If the enum value is decorated with the DescriptionAttribute attribute, its Description value is returned. Otherwise, the name of the enum value is returned.
        • ResourceKeyToResourceConverter - A converter that performs a resource lookup, using the conversion value as a resource key.
        • ValueConverterGroup - An IValueConverter which contains a list of IValueConverters and invokes their Convert or ConvertBack methods in the order that they exist in the list. This allows for modular value converters to be "piped" together to achieve complex conversions.
        • XamlToObjectConverter - An IValueConverter which creates a .NET object from the XAML contained in an XmlElement. The object created can be used as the content of a WPF control or ui element, such as the ContentPresenter. The inner XML of the XmlElement passed to the converter must contain valid XAML.
      • DataContextSpy - Exports an element tree's DataContext to objects external to the tree itself.
    • Input
      • CommandGroup - A command that aggregates other commands into a group and operates on them as an atomic unit.
      • SmartRoutedCommand - A RoutedCommand which allows its subclasses to provide default logic for determining if they can execute and how to execute.
    • Markup
      • IfFullTrustExtension - This markup extension conditionally instantiates the XAML you pass it if and only if the application is running in full-trust.
    • Panels
      • DragCanvas - A Canvas which manages dragging of the UIElements it contains.
      • Panel3D - A panel that lays its children out in 3D space and provides animated movement of the children.
  • ServiceProviders
    • UI
      • ListViewDragDropManager - Manages the dragging and dropping of ListViewItems in a ListView.
      • ListViewItemDragState - Exposes attached properties used in conjunction with the ListViewDragDropManager class. Those properties can be used to allow triggers to modify the appearance of ListViewItems in a ListView during a drag-drop operation.
      • UnloadedManager - A service provider class which provides a means of releasing resources when a FrameworkElement's Unloaded event fires. If the DataContext of the element implements IUnloadable, it's Unload method will be invoked when the elements Unloaded event fires.

    Revision History

    Date Assembly Version Notes
    November 11, 2006

    Created the article.

    November 28, 2006

    Added the CenteredContentControl and updated the source code download.

    January 24, 2007

    Added the ListViewDragDropManager, ListViewItemDragState, and DragAdorner classes. Also fixed broken links to articles that were moved. Updated the source code download.

    February 1, 2007

    Fixed a couple of bugs in the ListViewDragDropManager (see the article for details). Updated the source code download.

    February 25, 2007

    Added the SmartTextBox control, and the UIElementAdorner. Refactored the DragAdorner and UIElementAdorner so that they share a base class. Used a bug fix created by William J. Roberts in the MouseUtilities class (read here for more details). Updated the source code download.

    April 13, 2007

    Fixed a minor bug in the ListViewDragDropManager, which is described in detail at the bottom of that class's article. Updated the source code download.

    July 13, 20082.0.0.0Added many classes to the library and fixed the many links that broke over time.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Josh Smith
Software Developer (Senior) Black Pixel
United States United States
Josh creates software, for iOS and Windows.

He works at Black Pixel as a Senior Developer.

Read his iOS Programming for .NET Developers[^] book to learn how to write iPhone and iPad apps by leveraging your existing .NET skills.

Use his Master WPF[^] app on your iPhone to sharpen your WPF skills on the go.

Check out his Advanced MVVM[^] book.

Visit his WPF blog[^] or stop by his iOS blog[^].

See his website Josh Smith Digital[^].

You may also be interested in...

Comments and Discussions

GeneralRe: Links to old blog Pin
Patrick Sears3-Sep-07 8:05
memberPatrick Sears3-Sep-07 8:05 
GeneralRe: Links to old blog Pin
normanr15-Oct-07 4:11
membernormanr15-Oct-07 4:11 
GeneralRe: Links to old blog Pin
Josh Smith15-Oct-07 4:16
mvpJosh Smith15-Oct-07 4:16 
GeneralWell done Pin
Majid Shahabfar17-Jul-07 8:27
memberMajid Shahabfar17-Jul-07 8:27 
GeneralRe: Well done Pin
Josh Smith17-Jul-07 8:50
mvpJosh Smith17-Jul-07 8:50 
GeneralAnother idea for WPF.JoshSmith Pin
Judah Himango17-Apr-07 6:15
memberJudah Himango17-Apr-07 6:15 
GeneralRe: Another idea for WPF.JoshSmith Pin
Josh Smith17-Apr-07 6:20
mvpJosh Smith17-Apr-07 6:20 
GeneralRe: Another idea for WPF.JoshSmith Pin
Judah Himango17-Apr-07 7:26
memberJudah Himango17-Apr-07 7:26 
I just need to learn to write WPF stuff; I could then write the damn thing myself instead of complaining to WPF god Josh Smith. Smile | :)

I've tinkered with WPF a bit...I was able to modify the WPF RichTextBox to automatically underline hyperlinks. I've played with some of the various WPF document classes as well, but that's the extent of my experience.

One thing that is discouraging me from learning WPF further is the tools. I'm using Cider to play with WPF in VS, and jeez, Cider is hardly alpha quality. Makes me run back to the functional WinForms designer. :p

By the way, Josh, how are you cooking up your XAML? Is that done with Cider? By hand?

Tech, life, family, faith: Give me a visit.
I'm currently blogging about: How men in the Catholic Church replaced Passover with Easter
The apostle Paul, modernly speaking: Epistles of Paul

Judah Himango

GeneralRe: Another idea for WPF.JoshSmith Pin
Josh Smith17-Apr-07 7:36
mvpJosh Smith17-Apr-07 7:36 
GeneralLearning WPF... Pin
Patrick Sears25-Mar-07 7:11
memberPatrick Sears25-Mar-07 7:11 
GeneralRe: Learning WPF... Pin
Josh Smith25-Mar-07 15:16
mvpJosh Smith25-Mar-07 15:16 
GeneralRe: Learning WPF... Pin
Patrick Sears25-Mar-07 16:25
memberPatrick Sears25-Mar-07 16:25 
GeneralRe: Learning WPF... Pin
Patrick Sears25-Mar-07 16:59
memberPatrick Sears25-Mar-07 16:59 
GeneralRe: Learning WPF... Pin
Josh Smith26-Mar-07 3:03
mvpJosh Smith26-Mar-07 3:03 
GeneralRe: Learning WPF... Pin
Josh Smith13-Apr-07 6:48
mvpJosh Smith13-Apr-07 6:48 
GeneralRe: Learning WPF... Pin
Patrick Sears13-Apr-07 7:45
memberPatrick Sears13-Apr-07 7:45 
QuestionScrollViewer on DragCanvas Pin
Member #38352805-Mar-07 5:34
memberMember #38352805-Mar-07 5:34 
AnswerRe: ScrollViewer on DragCanvas Pin
Josh Smith6-Mar-07 3:21
mvpJosh Smith6-Mar-07 3:21 
GeneralRe: ScrollViewer on DragCanvas [modified] Pin
NiruPama_T7-Mar-07 6:12
memberNiruPama_T7-Mar-07 6:12 
QuestionClick on dragCanvas Pin
moondaddy24-Feb-07 17:52
membermoondaddy24-Feb-07 17:52 
AnswerRe: Click on dragCanvas Pin
Josh Smith25-Feb-07 10:26
mvpJosh Smith25-Feb-07 10:26 
QuestionRe: Click on dragCanvas Pin
moondaddy26-Feb-07 8:53
membermoondaddy26-Feb-07 8:53 
AnswerRe: Click on dragCanvas Pin
Josh Smith26-Feb-07 9:03
mvpJosh Smith26-Feb-07 9:03 
QuestionProblem using CenteredContentControl in C# Pin
DaSch-Productions19-Feb-07 7:45
memberDaSch-Productions19-Feb-07 7:45 
AnswerRe: Problem using CenteredContentControl in C# Pin
Josh Smith22-Feb-07 3:33
mvpJosh Smith22-Feb-07 3:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.180111.1 | Last Updated 13 Jul 2008
Article Copyright 2006 by Josh Smith
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid