Sunday, September 04, 2011

How To Make A Borderless WPF Windows Movable

Say you have a borderless WPF window (WindowStyle="None"), the problem arises, how can one still move/drag the window around on the desktop (as there simply is no more window title bar)?

It's actuelly pretty simple:

MouseDown += delegate { DragMove(); };

Thanks to Marlon for this hint.

Saturday, September 03, 2011

Is Your WPF ProgressBar Eating Up Unnecessary CPU Cycles?

When your WPF ProgressBar is causing lots of CPU usage, even if it is not visible any more, this most likely is caused by the IsIndeterminate property, which - when set to true - simply continues the animation to be running in the background.

One solution is to bind the IsIndeterminate property to the same underlying value as the Visibility property, for example something like this:

<ProgressBar IsIndeterminate="{Binding IsBusy}" 

Visibility="{Binding IsBusy,
Converter={StaticResource VisibilityConverter}}"/>

The IsBusy property of the bound DataSource can then represent whatever condition is suited in this scenario.

Thanks to Adam for this tip!