Хорошо, так как HB на меня напал, вот класс: p
public class CustomCursor
{
private System.Windows.Input.Cursor _cursor = null;
public System.Windows.Input.Cursor Cursor
{
get
{
if (_cursor == null)
_cursor = GetCursor();
return _cursor;
}
}
public string RelativePath { get; set; }
public CustomCursor()
{
}
public CustomCursor(string relativePath)
{
RelativePath = relativePath;
}
public System.Windows.Input.Cursor GetCursor()
{
if (RelativePath == null)
throw new ArgumentNullException("You must set RelativePath first");
string directory = Directory.GetCurrentDirectory();
string absPath = directory + '\\' + RelativePath;
if (!File.Exists(absPath))
throw new FileNotFoundException();
return new System.Windows.Input.Cursor(absPath);
}
}
Используйте в коде, подобном этому:
this.Cursor = new CustomCursor("grab.cur").Cursor;
Или объявите в xaml:
<local:CustomCursor x:Key="MyCursor" RelativePath="grab.cur"/>
И ссылка такая:
this.Cursor = (FindResource("MyCursor") as CustomCursor).Cursor;