共用方式為


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

屬性值

如果未設定 OverrideCursor,則覆寫數據指標或 null

範例

下列範例顯示 RadioButton 的事件處理程式,用來切換單一專案與整個應用程式之間的游標變更範圍。 如果引發事件的控制項是 rbScopeElementRadioButton,則會設定表示游標變更範圍的旗標,且 OverrideCursor 設定為 null。 如果引發事件的控件是 rbScopeApplicationRadioButton,則會設定表示游標變更範圍的旗標,並將 OverrideCursor 設定為名為 DisplayAreaBorder 控件的 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 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

備註

OverrideCursor 設定為 的 Cursor 將會套用至整個應用程式。

若要清除覆寫 Cursor,請將 OverrideCursor 設定為 null

OverrideCursor 設定為 None 會強制不顯示滑鼠游標,但仍會處理滑鼠事件。

適用於