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 を示しています。これは、1 つの要素とアプリケーション全体の間でカーソル変更のスコープを切り替えるために使用されます。 イベントを発生させたコントロールが の場合、 rbScopeElementRadioButtonカーソル変更のスコープを示すフラグが設定され OverrideCursor 、 が に null設定されます。 イベントを発生させたコントロールが の場合、rbScopeApplicationRadioButtonカーソル変更のスコープを示すフラグが設定されOverrideCursor、 という名前DisplayAreaのコントロールの Border プロパティに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

注釈

Cursorに設定されている OverrideCursor は、アプリケーション全体に適用されます。

オーバーライド Cursorをクリアするには、 を に設定 OverrideCursor します null

を にNone設定OverrideCursorすると、マウス カーソルは強制的に表示されませんが、マウス イベントは引き続き処理されます。

適用対象