Click here to Skip to main content
15,891,253 members
Articles / Desktop Programming / XAML

Search Selectable Virtual List

Rate me:
Please Sign up or sign in to vote.
5.00/5 (7 votes)
3 Jan 2013CPOL5 min read 31.4K   1K   15  
This article is the part 3 of the data display Performance Optimization series. It talks about performing multiple searches against the virtual list.
using System;
using System.ComponentModel;

namespace  SearchableSelectableVirtualList
{
	public class Employee : ISelectable, INotifyPropertyChanged
	{
		private string _name;

		public Employee()
		{
			IsSelected = false;
			HasRemoved = false;
		}

		public string Name
		{
			get { return _name; }
			set
			{
				_name = value;
				OnPropertyChanged("Name");
			}
		}

		private bool _isSelected;
		public bool IsSelected
		{
			get { return _isSelected; }
			set
			{
				_isSelected = value;
				OnPropertyChanged("IsSelected");
			}
		}

		private bool _hasRemoved;
		public bool HasRemoved
		{
			get { return _hasRemoved; }
			set
			{
				_hasRemoved = value;
				OnPropertyChanged("HasRemoved");
			}
		}

		public override bool Equals(object obj)
		{
			var employee = obj as Employee;
			if (employee == null)
				return false;
			return employee.Name == Name;
		}

		public override int GetHashCode()
		{
			return base.GetHashCode() + Name.GetHashCode();
		}

		public event PropertyChangedEventHandler PropertyChanged;
		public void OnPropertyChanged(string name)
		{
			PropertyChangedEventHandler handler = PropertyChanged;
			if (handler != null)
			{
				handler(this, new PropertyChangedEventArgs(name));
			}
		}
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

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


Written By
Software Developer (Senior)
Canada Canada
I am a passionated software developer / engineer with strong desire to develop in a simple, fast, beautiful way with the skillset such as simple design, refactoring, TDD. i worked in J2EE for about 5 years, now i work as a .NET devleoper.

Comments and Discussions