Mouse.OverrideCursor Свойство
Определение
Важно!
Некоторые сведения относятся к предварительной версии продукта, в которую до выпуска могут быть внесены существенные изменения. Майкрософт не предоставляет никаких гарантий, явных или подразумеваемых, относительно приведенных здесь сведений.
Получает или задает курсор для всего приложения.
public:
static property System::Windows::Input::Cursor ^ OverrideCursor { System::Windows::Input::Cursor ^ get(); void set(System::Windows::Input::Cursor ^ value); };
public static System.Windows.Input.Cursor OverrideCursor { get; set; }
static member OverrideCursor : System.Windows.Input.Cursor with get, set
Public Shared Property OverrideCursor As Cursor
Значение свойства
Переопределенный курсор или значение null
, если свойство OverrideCursor не установлено.
Примеры
В следующем примере показан обработчик событий для , который используется для RadioButton переключения область изменения курсора между одним элементом и всем приложением. Если элемент управления, вызвав которому событие, — , rbScopeElement
RadioButtonфлаг, обозначающий область изменения курсора, устанавливается и OverrideCursor имеет значение null
. Если элемент управления, вызвав которому событие, является rbScopeApplication
RadioButton, устанавливается флаг, обозначающий область изменения курсора, и OverrideCursor устанавливается в Cursor свойство Border элемента управления с именем DisplayArea
.
// Determines the scope the new cursor will have.
//
// If the RadioButton rbScopeElement is selected, then the cursor
// will only change on the display element.
//
// If the Radiobutton rbScopeApplication is selected, then the cursor
// will be changed for the entire application
//
private void CursorScopeSelected(object sender, RoutedEventArgs e)
{
RadioButton source = e.Source as RadioButton;
if (source != null)
{
if (source.Name == "rbScopeElement")
{
// Setting the element only scope flag to true
cursorScopeElementOnly = true;
// Clearing out the OverrideCursor.
Mouse.OverrideCursor = null;
}
if (source.Name == "rbScopeApplication")
{
// Setting the element only scope flag to false
cursorScopeElementOnly = false;
// Forcing the cursor for all elements.
Mouse.OverrideCursor = DisplayArea.Cursor;
}
}
}
' Determines the scope the new cursor will have.
'
' If the RadioButton rbScopeElement is selected, then the cursor
' will only change on the display element.
'
' If the Radiobutton rbScopeApplication is selected, then the cursor
' will be changed for the entire application.
'
Private Sub CursorScopeSelected(ByVal sender As Object, ByVal e As RoutedEventArgs)
Dim source As RadioButton = CType(e.Source, RadioButton)
If (source.Name = "rbScopeElement") Then
' Setting the element only scope flag to true.
cursorScopeElementOnly = True
' Clearing out the OverrideCursor.
Mouse.OverrideCursor = Nothing
End If
If (source.Name = "rbScopeApplication") Then
' Setting the element only scope flag to false.
cursorScopeElementOnly = False
' Forcing the cursor for all elements.
Mouse.OverrideCursor = DisplayArea.Cursor
End If
End Sub
Комментарии
Объект , CursorOverrideCursor для которому задано значение , будет применяться ко всему приложению.
Чтобы очистить переопределение Cursor, задайте для значение null
OverrideCursor .
Если задать значение OverrideCursor , None курсор мыши не будет отображаться, но события мыши по-прежнему обрабатываются.
Применяется к
Обратная связь
https://aka.ms/ContentUserFeedback.
Ожидается в ближайшее время: в течение 2024 года мы постепенно откажемся от GitHub Issues как механизма обратной связи для контента и заменим его новой системой обратной связи. Дополнительные сведения см. в разделеОтправить и просмотреть отзыв по