Binding Multiple Selection in RadListBox

Add Comment | Mar 09, 2015

Telerik quietly added a feature to their WPF RadListBox in their 1Q 2015 update that is coincidentally a feature I needed in a current project. The feature is the ability to bind the selected items in the RadListBox.

The Problem

The out of the box ListBox as well as Telerik’s RadListBox both have a SelectedItems property. Unfortunately, for whatever reason neither support binding to the property.

My current project is a WPF Prism application with specialized module loading. The application will live on a Terminal Server with all modules installed, so the need is to load the modules based on the logged-on user. The objects in play are the user and module. The user contains a collection of the modules it is assigned.

This use case can be approached in different ways. The approach I chose involves using two list boxes. The left list box contains a list of the users defined for the system. The right list contains a list of all the modules. The selections shown in the modules list box are changed as the currently selected user is changed.


The Resolution

The demo project addresses the problem in a simplified manner. There is no dependency on Prism or any other libraries other than the latest Telerik Devcraft tools for WPF; specifically, the RadListBox. Features in my solution have been scaled down to focus on the multiple selection binding.

The implementation of the user and module objects are pretty straightforward with one exception. The modules contained in the user object need to be managed by an ObservableCollection<T>, or a collection that implements INotifyCollectionChanged and INotifyPropertyChanged.

public sealed class AppUser
    public AppUser()
        Modules = new ObservableCollection<AppModule>();
    public string DisplayName { get; set; }
    public string UserName { get; set; }
    public ObservableCollection<AppModule> Modules { get; private set; }
    public override string ToString()
        return DisplayName ?? UserName ?? "(No Name)";

You might think that you could simply bind to the SelectedItems and call it a day. Unfortunately, that doesn’t work. Telerik decided to keep the behavior of the out of the box list box for that property. Instead they implemented an attached behavior.

<!-- cannot bind to the selected items this way -->
<telerik:RadListBox Grid.Column="1" x:Name="ModulesListBox"
                    ItemsSource="{Binding Modules}"
                    SelectedItems="{Binding SelectedUser.Modules}"
                    SelectionMode="Multiple" />

The behavior we want is available in the ListBoxSelectedItemsBehavior. Specifically, we use the SelectedItemsSource property. That will give us the selection behavior we want.

<telerik:RadListBox Grid.Column="1" x:Name="ModulesListBox"
         ItemsSource="{Binding Modules}"
                      "{Binding SelectedUser.Modules}"
         SelectionMode="Multiple" />

The modules assigned to the user will follow in the module’s list box as we change the selection in the user’s list box with the ListBoxSelectedItemsBehavior in place.


This new behavior fills a gap in functionality present in the RadListBox and it’s especially valuable in keeping implementation details from leaking into your view in an MVVM architecture. It seems like such a small thing, but features like this go a long way in making 3rd party tooling valuable within my organization.

First PC Build (Part 2)

Add Comment | Oct 11, 2014

I apologize for the delay in getting part 2 done. There have been so many things going on including an ongoing love affair with Skyrim.

I struggled with how to approach this article, because the world doesn’t need another “how-to build a PC” article. I settled on a brief treatise of my experience

Build Order

There are many resources available online to give you step-by-step instructions for building your PC. There are also the instructions provided by the component providers. For instance, both the motherboard and the case came with directions. The problem is that they’re all different.

This was the first challenge with doing my first build. I had to build up the confidence to go out on my own and determine what the right order was going to be. I did this by stepping back and taking some time to look and touch everything.

I took things out of the boxes, looked at connectors and cables, and overall just tried to get a good picture of how everything would fit and how I’d run cables. I looked at the motherboard diagrams and compared all of the documentation against all of the other documentation.

It did the trick. Much like I’d approach a software problem I was able to break things down into smaller tasks. There’s no point of giving you an order, because the order your build will vary. The case you choose may mean you need to put the PSU in first. You may even have to install the graphics card with the motherboard before putting it in the case.

The main advice I can offer is to take your time. Don’t rush.

Motherboard Assembly

When I say assembly I don’t mean you assembling the motherboard. I mean the few components that make up the assembly including the motherboard, RAM, CPU, and the cooler. I took more time on this step than any other. Getting it together also gave me a big confidence boost.

My assembly included my ASUS motherboard, Intel i7 CPU, and a Dark Rock 3 CPU cooler. I knew that because of it’s size and the way it attaches to the motherboard that I’d have to put it all together before putting the motherboard in the case.

Reading the documentation on the CPU will make you worry. The CPU is fragile and connecting it is fraught with disaster, because bending pins is easy. It turns out with a quality motherboard that everything lines up nicely and Asus made it hard to screw up – if you read the documentation or have done it before and know what you’re doing.

The most unclear part of the assembly is applying the thermal paste. Not too thin. Not too thick. No bubbles. Spread evenly over the entire surface. That sounds simple enough, but define not too thin and not too thick. You can only guess. I decided a safe thickness would be to spread it enough to be thorough, but thin enough so that it wouldn’t ooze out when I pressed the cooler to it. It seemed to do the trick, but I don’t have a warm and fuzzy feeling that it’ll be fine long term.

Installing the motherboard with a giant, heavy cooler on it can be tricky. This is another instance where pre-planning paid off. I had already test fit the motherboard in the case, so I knew how it would drop in and where the posts were.

Cable Management

I know I’m skipping over a lot of things. However, after the motherboard everything else was plug and play. One thing that is worth talking about is cable management. I mentioned in part 1 of the article that aesthetics is important to me. My case has a window in the side, and I want things to look tidy and professional.

I spent time before plugging anything in to decide how I wanted to run cables. Luckily, my case had plenty of room behind the motherboard for some of the fatter high quality cables. I utilized it. Don’t be afraid to unplug and reroute if you don’t like the way it looks. I did several times.

The better quality cables look nicer, and they come with zip ties and even velcro ties. However, in my opinion the best look is when the cables are straight and get out of the way as soon as possible. A zip tied set of cables will make it easier for maintenance, but they still don’t look good.


A picture is worth a thousand words, so I leave you with a few pictures and  a few words.

External | Internal | Window | Night Shot

I had a great time putting everything together, and most importantly I’d do it again. My beast has been running for a couple of months now dedicated to gaming and Photoshop. It does both amazingly.

First PC Build (Part 1)

Add Comment | Aug 05, 2014

A couple of months ago I made the decision to build myself a new computer. The intended use is gaming and for using the last real version of Photoshop. I was motivated by the poor state of console gaming and a simple desire to do something I haven’t done before – build a PC from the ground up.

I’ve been using PCs for more than two decades. I’ve replaced a component hear and there, but for the last 10 years or so I’ve only used laptops. Therefore, this article will be written from the perspective of someone familiar with PCs, but completely new at building. I’m not an expert and this is not a definitive guide for building a PC, but I do hope that it encourages you to try it yourself.

Component List


There was a lot of research necessary, because building a PC is completely new to me, and I haven’t kept up with what’s out there. The first thing you want to do is nail down what your goals are. Your goals are going to be driven by what you want to do with your computer and personal choice. Don’t neglect the second one, because if you’re doing this for fun you want to get what you want. In my case, I focused on three things: performance, longevity, and aesthetics.

The performance aspect is important for gaming and Photoshop. This will drive what components you get. For example, heavy gaming use is going to drive your choice of graphics card.

Longevity is relevant to me, because I don’t want to be changing things out anytime soon for the next hot game. The consequence of performance and longevity is cost.

Finally, aesthetics was my next consideration. I could have just built a box, but it wouldn’t have been nearly as fun for me. Aesthetics might not be important to you. They are for me. I also like gadgets and that played into at least one purchase for this build.

I used PC Part Picker to put together my component list. I found it invaluable during the process and I’d recommend it to everyone. One caveat is that I wouldn’t trust the compatibility aspects. It does a pretty good job of not steering you wrong, but do your own research.

The rest of it isn’t really sexy. I started out with what appealed to me and then I made changes and additions as I dived deep into researching each component and interaction I could find.

The resources I used are innumerable. I used reviews, product descriptions, forum posts (praises and problems), et al. to assist me. I also asked friends into gaming what they thought about my component list. And when I got near the end I posted my list to the Reddit /r/buildapc forum. I cannot stress the value of extra sets of eyeballs and first hand experiences.

Some of the resources I used:

PC Part Picker
Tom’s Hardware


PC Part Picker favors certain vendors. You should look at others too. In my case I found their favorites to be the best. My priorities were out-the-door price and shipping time.

I knew that once I started getting parts I’d want to start building. Luckily, I timed it well and everything arrived within the span of a few days. Here are my opinions on the vendors I ended up using in alphabetical order. is a good, reliable choice. They have excellent customer service in my experience, and I knew I wouldn’t have trouble with them. However, shipping time is often a problem when you use their free shipping unless you order expensive items (I’ve found items over $100 ship quickly). Ultimately though, price wasn’t always the best and their collection of sales tax in my state turned me off them.

I did purchase my case from them. I ordered the mouse as well, but I cancelled after it was stuck four days in a “shipping soon” state. I purchased the mouse locally.

Best Buy is not my favorite place to do business. There’s a lot of history with poor, uninterested sales representatives and they used to have a lot of bad anti-consumer policies. That’s a lot better now, but the bad taste is still in my mouth. I ended up purchasing the accessories from them including mouse (locally) and headphones.

NCIX is a company that I’ve never heard of before. It popped up as a recommendation for my CPU cooler on PC Part Picker. I didn’t do a lot of research on the company, because their policy on you buying insurance for your orders turned me off. That policy makes it clear to me that the company finds me responsible for the shipment once it leaves their dock. That’s not right, and may run afoul of state laws. Regardless they shipped my CPU cooler quickly and I didn’t have a problem. is a well known company. I had never done business with them, but I’m glad I did. They shipped quickly and provided good visibility over everything. The prices were also the best in most cases. My main complaint is that they have a lot of exchange only return policies on components. To their credit those policies are listed in the cart underneath each item. The visibility tells me that they’re not playing any shenanigans and made me comfortable dealing with that risk. The vast majority of what I ordered came from them.

Coming Next

In the next part I’ll tackle my build experience.

Single-Click Checkbox in RadGridView

Add Comment | Jun 05, 2014

The Telerik RadGridView for WPF is a flexible visual control for displaying and manipulating tables of data. It’s not without it’s quirks though. I ran into one of those quirks recently.

The behavior of the RadGridView requires that you first activate the cell for editing. That enables the editing controls underneath. Although that provides better editing capabilities, it also can be unintuitive. In my case I don’t want my users to have to click a checkbox value twice in order to change the value.

This can be solved easily by setting the EditTriggers and AutoSelectOnEdit properties to CellClick and True respectively. Unfortunately, the story doesn’t end there. You would think you could set those properties in a style with a TargetType of GridViewCheckBoxColumn. You’d be wrong.

<!-- This works -->
<telerik:GridViewCheckBoxColumn Header="Flag #1"
      DataMemberBinding="{Binding Flag1}"
      EditTriggers="CellClick" AutoSelectOnEdit="True"/>

<!-- This doesn’t work -->
<Style TargetType="{x:Type telerik:GridViewCheckBoxColumn}">
      <Setter Property="EditTriggers" Value="CellClick" />
      <Setter Property="AutoSelectOnEdit" Value="True" />

Telerik told me that is the correct, expected behavior, because the columns in the RadGridView are not visual elements. Their explanation is that the Style property comes from the base class FrameworkContentElement, but the column objects aren’t visual elements. That may be an implementation truth, but that doesn’t make the behavior correct or expected.

It’s unintuitive that the GridViewCheckBoxColumn exposes a Style property that cannot be used properly, but there it is. At least there’s a way to get the desired effect.

Restarting a Surface Pro 2

One Comment | Dec 09, 2013

Last Friday I encountered a problem resuming from sleep with my brand new Surface Pro 2. Of course this happened as I was getting everything ready to leave and catch a flight.

I had just put the Surface to sleep and realized I needed to get some information first. I tried to resume and nothing. After some basic troubleshooting I called Microsoft technical support.

Their technical support walked me through a few things including holding the power button down for longer then is normal to hard reset it. However, the magic tip was how to simulate the battery being removed.

To simulate the battery being removed and reinserted you hold down the Power and Volume Up buttons. And then release the Power button once you see the Surface logo. You go into a hardware setup screen. You exit from there and your Surface will restart as normal.

CryptoLicensing Evaluation

Add Comment | Nov 28, 2013

The software you write is valuable. Therefore, it should be protected. When you provide software for sale you need a mechanism to ensure it’s used within your purview. That mechanism usually involves licensing and copy-protection.

Enter CryptoLicensing

LogicNP handles the licensing and copy-protection using a military strength cryptographic technology. And it does so using a simple API that delivers all of the features you’d expect.

The webpage for CryptoLicensing lists all of the features. But, the following example demystifies the licensing process and proves how easy the software is to use.

Licensing Example

The documentation that comes with CryptoLicensing provides an example that is a good starting point.

The first thing you’ll do is create a licensing project using the CryptoLicensing Generator application. This allows use to create a key and any number of individual licenses for your application. The key is embedded in your application; and the licenses are normally provided to your end users. In the example, the license is embedded.


I took the example application a step further by encapsulating the licensing object in a special class. The implementation consists of a validation method and a property that provides a message that indicates the result of the validation.

The class implements IDisposable, because the CryptoLicense object does. There are areas that can be improved in my implementation. For example, you might want to keep the key and license strings as SecureString objects to keep them away from prying eyes.

public sealed class LicenseValidator : IDisposable
    readonly CryptoLicense licValidator;
    bool isDisposed = false;
    const string ValidationKey = "AMAAMAC…emkq==";

    public LicenseValidator()
        licValidator = new CryptoLicense();
        licValidator.ValidationKey = ValidationKey;

    public void Dispose()
        isDisposed = true;

    public string ResultMessage { get; private set; }

    public bool ValidateLicense(string licCode)
        if (string.IsNullOrEmpty(licCode))
            throw new ArgumentNullException("licCode");
        if (isDisposed)
            throw new ObjectDisposedException("LicenseValidator");

        licValidator.LicenseCode = licCode;

        var status = licValidator.Status;
        ResultMessage = status.ToString();

        return (status == LicenseStatus.Valid);

The LicenseValidator class is used at the start point of your application. I removed the reference to the startup window from App.xaml for my WPF application. And then I overloaded OnStartup in my App class.

protected override void OnStartup(StartupEventArgs e)

    using (var validator = new LicenseValidator())
        string lic = "FgAAAAhH…vKldV9DE";

        if (validator.ValidateLicense(lic))
            this.MainWindow = new MainWindow();
            MessageBox.Show("License validation failed ("
                + validator.ResultMessage + ")");

There is a glaring problem with this licensing example. It works, but the licensing key is hardcoded. And that’s not useful nor is it good practice.

The software provides three built-in ways of storing the license key. You can embed it as a resource in the assembly; although that is only slightly better than putting it in your code. You can also save it to a file or in the Registry.

The file and Registry options are the most useful, because they don’t tie the license code to your application. You then need a method of obtaining the license code from the user. CrytoLicensing has you covered there as well.

The EvaluationInfoDialog provides a mechanism to enter your license key in addition to verifying evaluation settings. The dialog works nicely enough to provide an easy way to enter a license. Unfortunately, it falls short in implementation.


The problem is that the EvaluationInfoDialog inherits directly from System.Windows.Forms.Form. That means it’s a Windows Forms implementation. The ShowEvaluationInfoDialog method of the CryptoLicense object take this specific concrete class. Therefore, you’re stuck with a dependency on the Windows Forms technology if you want to use the built-in behavior and pattern. This is a poor design decision. It should have been implemented as an interface with one or two external concrete implementations.

Of course, there’s nothing stopping you from implementing your own dialog. Unfortunately, you’ll be on your own for the entire implementation. It’s a shame LogicNP didn’t implement this as well as the rest of their software. I  grudgingly added a reference to the System.Windows.Forms assembly for my WPF demo purposes.

The changes to my LicenseValidator class are minor. The signature of the ValidateLicense method changes. It no longer takes a license code as an argument. Instead, I attempt to load the license within that method. A helper method to show the dialog is also added.

public bool ValidateLicense()
    if (isDisposed)
        throw new ObjectDisposedException("LicenseValidator");

    if (!licValidator.Load())
        if (!GetLicense())
            ResultMessage = "License entry cancelled";
            return false;

    var status = licValidator.Status;
    ResultMessage = status.ToString();

    return (status == LicenseStatus.Valid);

private bool GetLicense()
    using (var dialog = new EvaluationInfoDialog(licValidator))
        dialog.ProductName = "License Validator";
        dialog.PurchaseURL = "";

        return licValidator.ShowEvaluationInfoDialog(dialog);

The changes to the App class are even simpler. I modify the method call, remove the license code variable, and I remove the message box, because the EvaluationInfoDialog shows what needs to be shown.

protected override void OnStartup(StartupEventArgs e)

    using (var validator = new LicenseValidator())
        if (validator.ValidateLicense())
            this.MainWindow = new MainWindow();

Beyond the Simple

That is only the beginning of the capabilities of CryptoLicensing. The demo illustrated a basic licensing situation. You will likely have more advanced needs.

The following are some of the licensing scenarios that you may need that the software supports:

Evaluation You define an evaluation license when you want your users to use your application for some limited duration. You can specify limits on days, execution count, total time used, et al.
Hardware-Locked This license option allows you to lock the license to a specific computer.
Activations You define a number of activations for the license, and a licensing service calculates a hardware-locked license for the computer that is being activated.
Concurrent This option is similar to the activated license. The difference is that the license is based on the number of activations at a given time. And a computer with an existing license can free it up for another to be activated.
With Features You can specify a license that enables specific features within your application, or you can define editions like Standard, Professional, and Enterprise.

The user interface within CryptoLicensing is setup with a series of tabs that have many options for defining your license. The first two define the main settings. And the second is related to .NET specific assemblies.


Picking the correct settings for your project can be overwhelming. LogicNP provided a great feature called profiles to help with this. This feature allows you to create and save a series of settings based on your custom license.

You can create your own profiles or use one of the two that they provide out of the box – a normal license and a 30-day evaluation.

Licensing Service

Some of the features of CryptoLicensing require a licensing service. These features include concurrent licenses and dynamically hardware-locking licenses.

The provided licensing service is implemented as a Web service. It includes support for major eCommerce providers including PayPal, Plimus, et al.

The software installation comes with a complete Visual Studio solution that you compile and run after setting a few configuration options.

Usage Reporting

The licensing service comes with an added benefit. It can track how your application is used. This is similar in implementation to the Customer Experience Program you see in applications like Microsoft Office.

The part the user doesn’t see is a website you host. The website provides different views each of which focus on an aspect of the reported data. Usage reporting can be helpful in determining what features need your development resources.

Good and the Bad

The following are my general opinions about what sets CryptoLicensing apart and areas that could be improved.

Likes Dislikes
  • Features
  • Documentation
  • Application support
  • User interface
  • Windows Forms lock-ins


CryptoLicensing has a robust set of features that all work within the same interface. That means you’ll be able to add licensing features without requiring much rework of your existing code.

The documentation is excellent. The formatting can use some work, but you cannot complain about the content. LogicNP went above a simple documentation file and included several sample applications and instructional videos.

When I started using CryptoLicensing I thought it was going to be limited to your basic .NET application. It turns out that it supports many application types including Windows Phone, Mono, Mono Android, Windows Store, Office Addins, Sharepoint WebParts, et al.

I have the same complaints about the user interface as I do with Crypto Obfuscator. It’s convoluted and could use some attention. It’s easy for a developer to understand and use, but you may have a non-developer assigning and managing license codes when a licensing server isn’t involved.

My biggest complaint is the lock-in to Windows Forms for a couple of the helper windows. The UsageReportingConsentForm is derived from the Form class just as the EvaluationInfoDialog I already mentioned. There’s no reason you cannot implement your own, but there’s no good reason the implementation has been locked into a stagnant windowing technology either.

The Skinny

Licensing your software is a necessity in many cases in order to protect your intellectual property. But, it’s also a distraction from the core business problem you’re trying to solve. CryptoLicensing removes the distraction with a short learning curve and a robust set of features.

CryptoLicensing does everything I need for licensing. I plan on using it for my future projects that require licensing.