ContentElement.RaiseEvent(RoutedEventArgs) ContentElement.RaiseEvent(RoutedEventArgs) ContentElement.RaiseEvent(RoutedEventArgs) ContentElement.RaiseEvent(RoutedEventArgs) Method

定義

引發特定路由事件。Raises a specific routed event. 要引發的 RoutedEvent 是在所提供的 RoutedEventArgs 執行個體內識別 (作為該事件資料的 RoutedEvent 屬性)。The RoutedEvent to be raised is identified within the RoutedEventArgs instance that is provided (as the RoutedEvent property of that event data).

public:
 virtual void RaiseEvent(System::Windows::RoutedEventArgs ^ e);
public void RaiseEvent (System.Windows.RoutedEventArgs e);
abstract member RaiseEvent : System.Windows.RoutedEventArgs -> unit
override this.RaiseEvent : System.Windows.RoutedEventArgs -> unit
Public Sub RaiseEvent (e As RoutedEventArgs)

參數

e
RoutedEventArgs RoutedEventArgs RoutedEventArgs RoutedEventArgs

RoutedEventArgs,包含事件資料,也會識別要引發的事件。A RoutedEventArgs that contains the event data and also identifies the event to raise.

實作

範例

下列範例會建立事件資料、 將事件識別碼附加至資料,然後引發自訂的路由的事件使用事件資料執行個體。The following example creates event data, appends the event identifier to the data, and then uses the event data instance to raise a custom routed event.

void RaiseTapEvent()
{
  RoutedEventArgs newEventArgs = new RoutedEventArgs();
  newEventArgs.RoutedEvent = MyCustomLink.TapEvent;
  //newEvent.SetSource(this);
  RaiseEvent(newEventArgs);
}
Private Sub RaiseTapEvent()
  Dim newEventArgs As New RoutedEventArgs()
  newEventArgs.RoutedEvent = MyCustomLink.TapEvent
  'newEvent.SetSource(Me)
  MyBase.RaiseEvent(newEventArgs)
End Sub

備註

e參數的型別為路由的事件的所有資料的通用基底類型; 不過,事件資料應該被授與為最特定的事件資料類型,可供所引發的事件,因為RoutedEventArgs衍生的類別包含實際的特定資料是針對特定的事件時,會引發這個事件的屬性。The e parameter is typed as the common base type for all routed event data; however, the event data should be given as the most specific event data type that is available for the event being raised, because RoutedEventArgs derived classes contain the actual specific data properties that are intended for the specific event when it is raised.

RoutedEventArgs 不是狀態屬性事件;它也會識別要引發哪個路由的事件。RoutedEventArgs is not just the state properties for the event; it also identifies which routed event to raise. 此事件引發的模式和路由的事件資料,同時與不同通用語言執行平台 (CLR)common language runtime (CLR)事件和資料類別,通常只包含事件相關的屬性。This event-raising pattern and the routed event data both differ from 通用語言執行平台 (CLR)common language runtime (CLR) events and data classes, which typically just contain properties that are related to the event.

適用於