แก้ไข

แชร์ผ่าน


FrameworkCompatibilityPreferences.ShouldThrowOnCopyOrCutFailure Property

Definition

Gets or sets a value that indicates whether a failed copy or cut operation in a TextBoxBase instance results in a ExternalException.

public:
 static property bool ShouldThrowOnCopyOrCutFailure { bool get(); void set(bool value); };
public static bool ShouldThrowOnCopyOrCutFailure { get; set; }
static member ShouldThrowOnCopyOrCutFailure : bool with get, set
Public Shared Property ShouldThrowOnCopyOrCutFailure As Boolean

Property Value

true if a failed copy or cut operation in a TextBoxBase instance results in a ExternalException; otherwise, false.

Remarks

If a clipboard operation fails, such as with a HRESULT 0x800401D0 (CLIPBRD_E_CANT_OPEN) error, a corresponding ExternalException (which is a type of ExternalException) is thrown.

Because the Win32 OpenClipboard API acts globally, well-written applications should call the corresponding CloseClipboard API as soon as they have completed their clipboard operations. Otherwise, other applications running in the same session will be unable to access clipboard functions.

In WPF, such a denial of access to the clipboard is normally ignored silently. However, applications can opt to receive an ExternalException upon failure by setting the ShouldThrowOnCopyOrCutFailure flag to true. However, opting to receive exceptions also requires the application to handle Cut and Copy RoutedUICommands through a CommandBinding, and then apply that binding to all TextBoxBase controls (TextBox and RichTextBox) in the application. The application should ensure that it handles ExternalExceptions resulting from copy and cut operations in the CommandBinding's Executed handler.

Applies to