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 。