Mouse.OverrideCursor Właściwość
Definicja
Ważne
Niektóre informacje odnoszą się do produktu w wersji wstępnej, który może zostać znacząco zmodyfikowany przed wydaniem. Firma Microsoft nie udziela żadnych gwarancji, jawnych lub domniemanych, w odniesieniu do informacji podanych w tym miejscu.
Pobiera lub ustawia kursor dla całej aplikacji.
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
Wartość właściwości
Przesłonięć kursor lub null
jeśli OverrideCursor nie został ustawiony.
Przykłady
W poniższym przykładzie przedstawiono procedurę obsługi RadioButton zdarzeń, która służy do przełączania zakresu zmiany kursora między pojedynczym elementem a całą aplikacją. Jeśli kontrolka, która wzbudziła zdarzenie, jest rbScopeElement
RadioButtonflagą , która oznacza zakres zmiany kursora jest ustawiona i OverrideCursor jest ustawiona na null
. Jeśli kontrolka, która wzbudziła zdarzenie, to rbScopeApplication
RadioButton, flaga, która określa zakres zmiany kursora, jest ustawiona i OverrideCursor jest ustawiona na Cursor właściwość Border kontrolki o nazwie 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
Uwagi
OverrideCursor Ustawiona Cursor wartość zostanie zastosowana do całej aplikacji.
Aby wyczyścić przesłonięcia Cursor, ustaw wartość OverrideCursornull
.
Ustawienie na OverrideCursor wartość spowoduje, że None kursor myszy nie będzie wyświetlany, ale zdarzenia myszy są nadal przetwarzane.
Dotyczy
Opinia
https://aka.ms/ContentUserFeedback.
Dostępne już wkrótce: W 2024 r. będziemy stopniowo wycofywać zgłoszenia z serwisu GitHub jako mechanizm przesyłania opinii na temat zawartości i zastępować go nowym systemem opinii. Aby uzyskać więcej informacji, sprawdź:Prześlij i wyświetl opinię dla