Monthly archives: August, 2012

Automation of User Interface in WPF

All basic control in WPF has a corresponding AutomationPeer class that implements all the basic functionality a user can do with that control. These classes are named ButtonAutomationPeer and so on. If a user can scroll it then so can you programmatically. All controls implementing AutomationPeer has a few methods in common and for us

Root password in Ubuntu

When installing Ubuntu Linux you’re only asked for a user password and never a root password. It is a security risk to use the root account but sometimes it is necessary. In Ubuntu I have been asked for the root password when doing Upgrades and since the root password isn’t set (not the same as

Binding WPF element to an object

When binding a WPF element to another WPF element you can use the ElementName property. But when binding to an Object you use the Source property instead. You don’t need to set the source in the element itself. If source isn’t set the system searches for a source set for the DataContext property further up

Element to element data binding in WPF

Data bindings has existed for quite some time in Windows Forms but in WPF it’s more powerful than ever. In this example I’ll show how to create simple databindings inbetween two WPF elements. Data bindings are created through the Bindings class. In this very simple example a label is declaratively bound to a slider so

Flags attribute for Enums

If you want to be able to use several of the enum options at once you can use the FLAGS attribute when declaring the enum. [Flags] public enum AccessRights : short { READ = 1, WRITE = 2, EXECUTE = 4 } To make it work you need to enumerate the fields in powers of

Enums in C#

An enum is a defined set of constants in a list. If you don’t give the enums any values they will start with 0 and count up. In this example we’ve forced the count up to start with 1. public enum SingleColors { RED = 1, GREEN, BLUE, YELLOW } You can change the type


Create a ram disk in Linux

Sometimes a ram disk can be useful to lower file access latency. This script will create a 120 Mb ram disk in a Linux environment. dd if=/dev/zero of=/dev/ram0 bs=1k count=131072 mke2fs -q -m0 /dev/ram0 mount /dev/ram0 /mnt/ramdisk It should be noted though that ram disks are highly dependent on continous power supply. If power is


%d bloggers like this: