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 事件處理程式,用來切換單一專案與整個應用程式之間的數據指標變更範圍。 如果引發事件的控制項是 rbScopeElementRadioButton,表示資料指標變更範圍的旗標已設定,且 OverrideCursor 設定為 null。 如果引發事件的控件是 rbScopeApplicationRadioButton,表示數據指標變更範圍的旗標已設定,並且OverrideCursor設定為Cursor名為 DisplayArea之控件的 Border 屬性。

// 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,請將 設定 OverrideCursornull

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

適用於