Showing posts with label cursor. Show all posts
Showing posts with label cursor. Show all posts

Thursday, January 3, 2013

How to Detect a Touch Screen (C#)

Just a quick note to show you how to detect a touch screen. This code could be used to hide the application cursor if the application is running on a touch screen device.

I hope it helps.

private bool HasTouchInput()
{
return Tablet.TabletDevices.OfType<TabletDevice>().Any(t => t.Type == TabletDeviceType.Touch);
}


Wednesday, July 16, 2008

How Do You Change the Cursor of a WPF App?

Changing the cursor of a WPF app is pretty simple. You can do it through procedural code as follows:
this.Cursor = Cursors.None;

There are several built in cursors such as a pen, cross, scroll, etc.
You can also use a custom cursor as follows:
this.Cursor = new Cursor("CustomCursorImage.jpg");

Because Cursor is a dependency property, it can also be used in XAML. Here are two examples on how to use custom cursors via XAML:

<Button Content="Wait" Cursor="Wait"/>

<Button Content="CustomCursorImage.jpg"/>