Entries by Peter Staev

LINQ Mysteries: The Distinct Function

Recently I had to use the Distinct function introduced in LINQ. My surprise was that depending on where you put the Distinct clause you will receive different results. Let us take the following example: Let dtAnswers be a DataTable that has two columns, named answer_value and answer_comment. What I was seeking as a result was […]

Passing DataSet to a WCF Method

Recently I’ve made a simple WCF service that had a method that takes a MemoryStream parameter. After some time I had to add another method that should take a whole DataSet as parameter. And then my problems begun! After I’ve added the method and refreshed the service reference of my client the proxy class generator […]

Creating a simple CheckListBox control in WPF

With .NET Framework 3.0 Microsoft has removed one control that I’ve liked and used a lot – the CheckListBox. But on the other hand with WPF the developer can easily create his own check list control. Here is how to create one yourself. Put a simple ListBox in your window: XAML: <Window x:Class=”winCustomPKChooser” xmlns=”http://schemas.microsoft.com/winfx/2006/xaml/presentation” xmlns:x=”http://schemas.microsoft.com/winfx/2006/xaml” […]

How to close a tab with mouse middle click?

When I had to do this I’ve searched all over the Internet for some information on how to implement such a feature, but I have found nothing. The main problem was how to detect on which tab exactly has the user clicked on. I haven’t found any method or property of the TabControl or TabPage […]

Password TextBox in WPF

In .NET Framework 3.0 (WPF) Microsoft have removed the property of a TextBox, which specifies whether the textbox is Password or Normal type. But in replacement they’ve introduced a new control named PasswordBox which is very simple and intuitive to use. Here is a simple example: XAML: <PasswordBox x:Name=”txtPassword” ToolTip=”Password” PasswordChar=”*” /> By default the […]