WPF Control: Listbox of checkbox with Search google-like

One thing that i like of WPF is the possibility of making easy-to-use controls to manage data.
A control that i use a lot of times to filter dataviews, charts, get queryes parameters and so on is a listbox of checkbox.
This isn't that special, but with ICollectionView and the possibility of having a fast way to filter results like the search box in google.com it become a really powerful tool.

I invite you to download the demo (link at the bottom of this page) to understand better.

Let's start from an example:
I have an observable collection of "Fruits", objects that contain a property "Name" and a property "Show" that indicates if the object has to be visualized or filtered.

To filter this collection i can use the ICollectionView, that permits to filter a collection and has a method Refresh() that reload the collection with the filter parameters.

So in the properties i add:
 class MyFruitCollection : ObservableCollection
    {

private ICollectionView filteredCollection;
public ICollectionView FilteredCollection { get { return filteredCollection; } }


and the filter string:

private string filter = "";
        public string Filter
        {
            get { return this.filter.ToUpperInvariant(); }
            set
            {
                if (this.filter != value)
                {
                    this.filter = value;
                    this.filteredCollection.Refresh(); //
Notice that i call Refresh() at every change of filter
                }
            }
        }


In the constructor of my collection i add some fruits(just for example) and i load the ICollectionView datasource:

        public MyFruitCollection()
        {
            this.Add(new MyFruit("Orange"));
            ...
            this.Add(new MyFruit("Watermelon"));

            this.filteredCollection = CollectionViewSource.GetDefaultView(this);
            this.filteredCollection.Filter = ContainsFilter;
        }

Then i set the filters on this method:

private bool ContainsFilter(object item)
        {
            var fruit = item as MyFruit;
            if (fruit == null)  //check if fruit is null
            {
                return false;
            }
            if (string.IsNullOrEmpty(this.Filter)) //check if search box is empty or null
            {
                return true; //show all items if there is no text in the search textbox
            }
            if (fruit.Name.ToUpperInvariant().Contains(this.Filter))
//checks if fruit.name contains the search text
            {
                return true;
            }
            return false; //if it doesn't contain anything don't show the item
        }


 Xaml is pretty simple, as usual it's all about databinding:

And this is the code behind:

    public partial class MainWindow : Window
    {

MyFruitCollection fruitCollection = new MyFruitCollection();

        public MainWindow()
        {
            InitializeComponent();
            this.DataContext = fruitCollection;
//notice that all the application is in binding
        }

...
}

The resul is pretty cool and it makes apps a lot more confortable, just try yourself :)
Download the example here:
http://mesta-automation.com/Downloads/Selection%20control.rar

A good (free) set of 240 icons

A big problem and a big waste of time for a programmer is the research of icons and images to associate to buttons, panels, toolbars and so on.
I really hated to do that with Google image-finder, so i searched a lot until i found a site that contained a million of icons.
Of course it can't exist that for every program i search in a database containing so many designs, so i want to show you a set of icons that in my opinion cover almost all that a programmer needs.
As usual remember that an icon should HELP the operator, not just be pretty. If you feel that the icon is not so meaningful, it's better to remove it and just leave text on the button (so the operator is forced to read it).
This is a small (and almost useless) preview of the set, that contains more useful icons for sure:

But i invite you to visit this page: http://www.iconarchive.com/category/application/aesthetica-2-icons-by-dryicons.html to see the complete set (that is really big, around 240 icons).
I want to point the attention on some icons:
- Accept, Add, Remove and Edit are pretty straightforward. I think that no one can do confusion with this set of icons.
- Back, Next, Down and Top are pretty useful too, even if i don't like to abuse of them because they are not always understandable if the context is not well defined.
- Info, Help, Search and Warning are awesome. It's impossible to don't understand what they means and they are similar to windows ones too.
- Lock - Unlock icons for password login is always useful.
- Charts, Folders, Databases, Home, Word and Calendar got always a use in programs, and they are included too.

The rest is quite trashy, or not so useful, but it always depends on what you are doing.
I really invite you to check out this set, downloadable from the bottom of this page:
http://www.iconarchive.com/category/application/aesthetica-2-icons-by-dryicons.html
selecting Linux (.png) files included (so you get the version with the set of 16x16 - 32x32 - 48x48 - 64x64 - 128x128 pixels)
Remember that if you use them you should read carefully the license, that permit a free use of this set, and to respect the work of this guys.