UserActivityRequestManager.UserActivityRequested 事件
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
對應用程式提出要求以建立隨選 UserActivity 物件時引發。
// Register
event_token UserActivityRequested(TypedEventHandler<UserActivityRequestManager, UserActivityRequestedEventArgs const&> const& handler) const;
// Revoke with event_token
void UserActivityRequested(event_token const* cookie) const;
// Revoke with event_revoker
UserActivityRequestManager::UserActivityRequested_revoker UserActivityRequested(auto_revoke_t, TypedEventHandler<UserActivityRequestManager, UserActivityRequestedEventArgs const&> const& handler) const;
public event TypedEventHandler<UserActivityRequestManager,UserActivityRequestedEventArgs> UserActivityRequested;
function onUserActivityRequested(eventArgs) { /* Your code */ }
userActivityRequestManager.addEventListener("useractivityrequested", onUserActivityRequested);
userActivityRequestManager.removeEventListener("useractivityrequested", onUserActivityRequested);
- or -
userActivityRequestManager.onuseractivityrequested = onUserActivityRequested;
Public Custom Event UserActivityRequested As TypedEventHandler(Of UserActivityRequestManager, UserActivityRequestedEventArgs)
事件類型
範例
protected override void OnNavigatedTo(NavigationEventArgs e)
{
base.OnNavigatedTo(e);
Windows.ApplicationModel.UserActivities.UserActivityRequestManager requestMgr = Windows.ApplicationModel.UserActivities.UserActivityRequestManager.GetForCurrentView();
requestManager.UserActivityRequested += UserActivityRequested;
}
private async void UserActivityRequested(
Windows.ApplicationModel.UserActivities.UserActivityRequestManager sender,
Windows.ApplicationModel.UserActivities.UserActivityRequestedEventArgs args)
{
// Instantiate an empty UserActivity object, or the application can reuse one from UserActivityChannel.GetOrCreateUserActivity
Windows.ApplicationModel.UserActivities.UserActivity userActivity = // app code to create a new UserActivity;
args.Request.SetUserActivity(userActivity);
}
備註
這個事件會在與建立 UserActivityRequestManager之檢視相關聯的執行緒上引發。