In this blog post I am going to demonstrate on how to manipulate cursor for WinRT UI control as like in WPF control.
In WPF, you will find a property (Cursor) in UI control which allows you to get/sets the cursor which displays when mouse pointer is over the UI (ex: Textbox) element. Whereas in WinRT environment there is no cursor property for each UI control instead we can manipulate the cursor used by the window using the current core window pointer cursor.
//Gets or sets the cursor used by the window.
In the below sample (referred from WinRTXamlToolkit samples) I have manipulated the cursor used by the window when hovering over (pointer entered and pointer exited event) the text block element.
private void txtBlock_PointerEntered_1(object sender, PointerRoutedEventArgs e)
//Store current cursor used by the window
m_defaultCursor = Window.Current.CoreWindow.PointerCursor;
//Set cursor of current core window
Window.Current.CoreWindow.PointerCursor = Cursor;
private void txtBlock_PointerExited_1(object sender, PointerRoutedEventArgs e)
//Reset pointer cursor on mouse pointer exits
Window.Current.CoreWindow.PointerCursor = m_defaultCursor;