Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / desktop / WPF

Mahhala – Bag o' Tricks

4.80/5 (2 votes)
14 Jun 2010CPOL4 min read 12.1K  
In this, my first edition of Mahhala, we will look at the awesome set of controls by Kevin Moore called Bag of Tricks (BOT).

Mahhala (a isiZulu word for free or without charge) is a new series that showcases some of the cool free WPF/Silverlight controls available…

“You can learn a lot by reading other people's source code. That's the idea behind this series, "The Weekly Source Code." You can certainly become a better programmer by writing code but I think good writers become better by reading as much as they can.” - Scott Hanselman

In this, my first edition of Mahhala, we will look at the awesome set of controls by Kevin Moore called Bag of Tricks (BOT). The BOT is one of the first set of controls available on the net (2005) and contains a huge selection of cool controls…

Source: http://bot.codeplex.com

License: The MIT License (MIT)

 

RG - Welcome Kevin, tell us a little more about yourself?

KM - I grew up in Iowa. I'm from Iowa State University. Computer Engineering, 2002. I worked at Microsoft until 2007--started out in the Windows Shell (remember Longhorn?) and moved on to work on WPF (remember when it was called Avalon?) my last three years. The Monday after getting my 5 year award, I gave notice and went to work for a small insurance services company with some former Microsoft co-workers. It was a short gig (8 months), but it taught me I could work as a dev and on my own. Since June 2008, I've been flying solo. I've done a wide range of projects and learned a lot of new technologies: iPhone, Flex, Ruby on Rails, JavaScript...and of course WPF and Silverlight. I recently joined forces with my former Microsoft co-worker, Robby Ingebretsen (@ingebretsen) to re-launch Pixel Lab (thinkpixellab.com). We make beautiful things out of pixels.

RG - What is the Bag o' Tricks?

KM - The BOT is a library I started to keep track of all of my WPF samples while I was working on V1 at Microsoft. We were creating new Alpha/Beta releases all the time internally and I was doing a bad job of making sure all of my old samples built on the newest release. I put them all together just so I had one thing to debug and it sorta snowballed from there.

RG - Which control in BOT is your favourite?

KM - I really like Graph. Mostly because it's been used and referenced by a lot of people. I think the look and the performance are pretty cool.

RG - How difficult is it to write controls that work in both WPF & Silverlight?

KM - I find if you think about targeting Silverlight, getting things to work in WPF later is pretty easy. There are a few things in WPF (like being able to directly control child elements, and OnRender) that I really miss in Silverlight, but there hasn't been anything (yet) that I can't get working both places.

RG - Which do you prefer?

KM - That's tough. I think Silverlight. My machines are all Mac now. I love being able to target a broad set of users. I love low-impact applications. While I miss some specific features in WPF, I don't see myself building anything WPF-specific for my own projects.

RG - And where can readers get hold of you?

KM - For specific questions on the Bag o' Tricks, please use the bug tracker and discussion forum on the BOT CodePlex page. Otherwise, please use the contact form on ThinkPixelLab.com

The BOT contains loads of cool controls but I want to highlight 2 of these… The first control is the TransitionPresenter! I recently used this in OpenPOS… Run OpenPOS and navigate between screens, the cool transition is done using this awesome control! I created a ContentControl and set it as my ContentRegion using PRISMs RegionManager. Every time I now navigate, this cool transition happens!

XML
<ContentControl>
    <ContentControl.Template>
        <ControlTemplate TargetType="{x:Type ContentControl}">
            <lib:TransitionPresenter Content="{TemplateBinding Content}">
                <lib:TransitionPresenter.Transition>
                    <lib:FadeTransition />
                </lib:TransitionPresenter.Transition>
            </lib:TransitionPresenter>
        </ControlTemplate>
    </ContentControl.Template>
</ContentControl>

Easy, isn’t it!!! Next on my list of favourites is the Graph…

If you ever used something like the TreeView, the Graph should feel very familiar:

XML
<lib:Graph NodesBindingPath="Children" CenterObject="{Binding}">
    <lib:Graph.NodeTemplate>
        <DataTemplate>
            <Border BorderBrush="Black" BorderThickness="2,2,2,2" 
			CornerRadius="6,6,6,6" Background="Lime">
                <TextBlock Text="{Binding Content}" Margin="5,2.5,5,2.5" />
            </Border>
        </DataTemplate>
    </lib:Graph.NodeTemplate>
</lib:Graph>

Oh, and if you are curious how Kevin looks, also check out the KevinButton:

And that is it!!!

Join me next week when I chat with Daniel Degtyarev, the creator of the Fluent Ribbon Control Suite. 

If you found this series useful, please kick it on DotNetKicks.com

License

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