【发布时间】:2013-05-22 21:00:00
【问题描述】:
Windows 应用商店应用程序库中的 Run 类是 SEALED 的,与旧桌面版本不同。我需要向它添加一个属性,当用户选择 Run 时我可以检索它。
是否可以将属性附加到我可以在代码中访问的密封 Run 类?
这是我的尝试:
public static readonly DependencyProperty MyIndexProperty =
DependencyProperty.RegisterAttached("MyIndex", typeof(int), typeof(Run), new PropertyMetadata(null));
public static int GetMyIndex(Run obj)
{
return (int)obj.GetValue(MyIndexProperty);
}
public static void SetMyIndex(Run obj, int value)
{
obj.SetValue(MyIndexProperty, value);
}
【问题讨论】:
-
您的尝试有问题吗?
-
是的。尝试在我的 C# 代码中访问 Run.MyIndex 将无法编译。代码在同一个命名空间中。
标签: c# xaml windows-store-apps