本文整理汇总了C#中DataTemplate类的典型用法代码示例。如果您正苦于以下问题:C#DataTemplate类的具体用法?C#DataTemplate怎么用?C#DataTemplate使用的例子?这里精选的类代码示例或许可以为您提供帮助。
示例1:RecursiveSettingInSystem publicvoidRecursiveSettingInSystem() { vartempObjects=new[]{ new{Name="Test1"}, new{Name="Test2"} };
vartemplate=newDataTemplate(typeof(BindableViewCell)){ Bindings={{BindableViewCell.NameProperty,newBinding("Name")}} };
varcell1=(Cell)template.CreateContent(); cell1.BindingContext=tempObjects[0]; cell1.Parent=newListView();
varcell2=(Cell)template.CreateContent(); cell2.BindingContext=tempObjects[1]; cell2.Parent=newListView();
varviewCell1=(BindableViewCell)cell1; varviewCell2=(BindableViewCell)cell2;
Assert.AreEqual("Test1",viewCell1.Name); Assert.AreEqual("Test2",viewCell2.Name);
Assert.AreEqual("Test1",viewCell1.NameLabel.Text); Assert.AreEqual("Test2",viewCell2.NameLabel.Text); }
原文链接:
http://www.jxszl.com/biancheng/C/556886.html