Wednesday, 22 December 2010


How many times did we want to know the size of a folder and all its sub-folders?

For me it has been always the case whenever I clean up my hard drive. It is just too tiring to right-click and check out the properties.

TreeSize (free) lets you do just that. The interface is a tree view which shows the sub-folders with their sizes.

Tuesday, 21 December 2010

Unpackage .msi file

A quick tip to unpackage the .msi file without installing the application:

MSIEXEC /a "msi file path" targetdir="install location"

The argument that works is "/a" which is for admin mode.

Sunday, 19 December 2010

WPF: How to disable controls?

How do I disable a Button in WPF?

Use - IsEnable property.

Using a WinForms user control in WPF

During WPF application development we are bound to face situation where we cannot port the WinForms user control to WPF, and will be forced to use the control in WPF window.

The steps below help us achieve that:

1) Add <WindowsFormsHost> control to the window

If needed remove the Height, Width and Margin property and use 'Stretch' for HorizontalAlignment and VerticalAlignment - to simulate the Dock=Fill.

2) Now we can add any WinForms control to the WindowsFormsHost.

For example if we have WinForms user control named UserControl1, we can write this code:
UserControl1 uc1 = new UserControl1();
winHost.Child = uc1;

- cheers

Friday, 17 December 2010

Moving from WinForms to WPF

1) TabControl:

- How to set the title on the TabItem control?

In WinForms we used the Text property, in WPF we have the Header property. The header property is of type object, so basically we can put 'anything' in the header - not just text.

2) TextBox:

- How to add scrollbar to TextBox?

Add these properties: HorizontalScrollBarVisibility="Visible" VerticalScrollBarVisibility="Auto"

3) Button:

- How to write a multi-line text on the button?

As expected this doesn't work
<Button.Content> Hello\rthere<Button.Content/>

We need to use a TextBlock as Content, and use a <LineBreak /> in the text.

For e.g.:
<TextBlock>Test<LineBreak/> button</TextBlock>

WinForms Dock=Fill in WPF

Today while designing a WPF form, I was using a TabControl and wanted to fill it entirely on the window.

In WinForms we would reach out to the Dock property of TabControl and select 'Fill'. However we do not have Dock property in WPF controls.

Solution: We can use the alignment properties to achieve the same effect:

<TabControl HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />

You will need to remove Height, Width and Margin properties of the control to make it fill.

Wednesday, 1 December 2010

Important Links:

What To Know Before Debating Type Systems:

C# Reactive Extensions - Buffer and Window

I was going through Buffer and Window in RX, thought a few examples would help clear the differences. First create a buffer of even numbe...