我创建了一个简单的 C# Windows 8 网格应用程序。
如果你不熟悉这个布局,这里有一个简短的解释:
我想要的很简单——一些自定义ItemDetailPages
。我希望能够单击 和 上的某些项目GroupDetailPage
并GroupedItemsPage
导航到自定义.xaml
文件,我可以在其中包含多个图像。
我确信有一种我错过了的简单方法,而且我也确信这些信息将对很多人有用,所以我将在这个问题上提供赏金。
到目前为止,我一直在努力做到这一点:
我CustomDataItem
在SampleDataSource.cs
课堂上创建了一个:
/// <summary>
/// Generic item data model.
/// </summary>
public class CustomDataItem : SampleDataCommon
{
public CustomDataItem(String uniqueId, String title, String subtitle, String imagePath, String description, String content, SampleDataGroup group)
: base(uniqueId, title, subtitle, imagePath, description)
{
this._content = content;
this._group = group;
}
private string _content = string.Empty;
public string Content
{
get { return this._content; }
set { this.SetProperty(ref this._content, value); }
}
private SampleDataGroup _group;
public SampleDataGroup Group
{
get { return this._group; }
set { this.SetProperty(ref this._group, value); }
}
}
然而,显然,增加ObservableCollection
private ObservableCollection<SampleDataGroup> _allGroups = new ObservableCollection<SampleDataGroup>();
public ObservableCollection<SampleDataGroup> AllGroups
{
get { return this._allGroups; }
}
使用不同的数据类型是不可能的。那么在这种情况下我该怎么办?
非常感谢。