我想自定义 Windows 8 Grid App 中的一些项目,与以下默认模板不同:
SampleDataItem(String uniqueId, String title, String subtitle, String imagePath, String description, String content, SampleDataGroup group)
对于某些数据项,我想添加一些 UI 控件,例如 mediaElement 或动画。对于其他人,我没有。
有什么办法可以解决这个问题吗?
提前致谢。
最佳答案
您需要为 Base 创建一个新的构造函数以使用新的自定义构造函数。像这样:
public abstract class SampleDataCommon : PrototypeCeA.Common.BindableBase
{
private static Uri _baseUri = new Uri("ms-appx:///");
//Base constructor
public SampleDataCommon(String uniqueId, String title, String subtitle, String imagePath, SolidColorBrush Background)
{
this._uniqueId = uniqueId;
this._title = title;
this._subtitle = subtitle;
this._imagePath = imagePath;
this._background = Background;
}
// new customized constructor
public SampleDataCommon(String uniqueId, String title, String subtitle, bitmapImage image, String description, String Author)
{
this._uniqueId = uniqueId;
this._title = title;
this._subtitle = subtitle;
this._description = description;
this._image = image;
this._author = author;
}
}
现在,您需要将这个新的构造函数调用到一个新的自定义类(或现有类)中以填充您的网格项。
- 我的英语很差,抱歉!
关于windows - 自定义 Windows 8 网格应用程序模板中的每个项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14614013/