UserActivity.State 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得此UserActivity (已發行或新增) 的狀態。
public:
property UserActivityState State { UserActivityState get(); };
UserActivityState State();
public UserActivityState State { get; }
var userActivityState = userActivity.state;
Public ReadOnly Property State As UserActivityState
屬性值
這個 UserActivity的狀態。
範例
UserActivity userActivity = await channel.GetOrCreateUserActivityAsync(activityId);
//if it's a new UserActivity associate metadata with it
if (userActivity.State == UserActivityState.New)
{
//required fields, SaveAsync() throws ArgumentNullException if not set
userActivity.ActivationUri = new Uri("rss-reader:article?" + article.Link);
userActivity.DisplayText = article.Title; //used for details tile text
//optional fields
userActivity.FallbackUri = article.Link;
//we don't have a website for the app, but the article can be viewed in a browser
userActivity.ContentUri = article.Link;
userActivity.VisualElements.Description = article.Summary; //optional
userActivity.ContentInfo = UserActivityContentInfo.FromJson(
@"{
""@context"": ""http://schema.org"",
""@type"": ""Article"",
""author"": ""John Doe"",
""name"": ""How to Tie a Reef Knot""
}");
await userActivity.SaveAsync();
}
備註
瞭解 UserActivity 是 New 與 Published 可用來判斷 GetOrCreateUserActivityAsync () 是否傳回新建立的 UserActivity 或先前建立的 UserActivity 。