本文整理汇总了C#中DataTemplate.CreateContent方法的典型用法代码示例。如果您正苦于以下问题:C# DataTemplate.CreateContent方法的具体用法?C# DataTemplate.CreateContent怎么用?C# DataTemplate.CreateContent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataTemplate
的用法示例。
在下文中一共展示了DataTemplate.CreateContent方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RecursiveSettingInSystem
public void RecursiveSettingInSystem ()
{
var tempObjects = new[] {
new {Name = "Test1"},
new {Name = "Test2"}
};
var template = new DataTemplate (typeof (BindableViewCell)) {
Bindings = { {BindableViewCell.NameProperty, new Binding ("Name")} }
};
var cell1 = (Cell)template.CreateContent ();
cell1.BindingContext = tempObjects[0];
cell1.Parent = new ListView ();
var cell2 = (Cell)template.CreateContent ();
cell2.BindingContext = tempObjects[1];
cell2.Parent = new ListView ();
var viewCell1 = (BindableViewCell) cell1;
var viewCell2 = (BindableViewCell) cell2;
Assert.AreEqual ("Test1", viewCell1.Name);
Assert.AreEqual ("Test2", viewCell2.Name);
Assert.AreEqual ("Test1", viewCell1.NameLabel.Text);
Assert.AreEqual ("Test2", viewCell2.NameLabel.Text);
}
示例2: Create
public void Create()
{
var template = new DataTemplate (typeof(SwitchCell));
var content = template.CreateContent();
Assert.That (content, Is.InstanceOf<SwitchCell>());
}
示例3: CreateContentType
public void CreateContentType()
{
var template = new DataTemplate (typeof (MockBindable));
object obj = template.CreateContent();
Assert.IsNotNull (obj);
Assert.That (obj, Is.InstanceOf<MockBindable>());
}
示例4: On
public void On()
{
var template = new DataTemplate (typeof (SwitchCell));
template.SetValue (SwitchCell.OnProperty, true);
SwitchCell cell = (SwitchCell)template.CreateContent();
Assert.That (cell.On, Is.EqualTo (true));
}
示例5: Text
public void Text()
{
var template = new DataTemplate (typeof (SwitchCell));
template.SetValue (SwitchCell.TextProperty, "text");
SwitchCell cell = (SwitchCell)template.CreateContent();
Assert.That (cell.Text, Is.EqualTo ("text"));
}
示例6: CreateContentValues
public void CreateContentValues()
{
var template = new DataTemplate (typeof (MockBindable)) {
Values = { { MockBindable.TextProperty, "value" } }
};
MockBindable bindable = (MockBindable)template.CreateContent();
Assert.That (bindable.GetValue (MockBindable.TextProperty), Is.EqualTo ("value"));
}
示例7: CreateContentBindings
public void CreateContentBindings()
{
var template = new DataTemplate (() => new MockBindable()) {
Bindings = { { MockBindable.TextProperty, new Binding (".") } }
};
MockBindable bindable = (MockBindable)template.CreateContent();
bindable.BindingContext = "text";
Assert.That (bindable.GetValue (MockBindable.TextProperty), Is.EqualTo ("text"));
}
示例8: SetBindingOverridesValue
public void SetBindingOverridesValue()
{
var template = new DataTemplate (typeof (MockBindable));
template.SetValue (MockBindable.TextProperty, "value");
template.SetBinding (MockBindable.TextProperty, new Binding ("."));
MockBindable bindable = (MockBindable) template.CreateContent();
Assume.That (bindable.GetValue (MockBindable.TextProperty), Is.EqualTo (bindable.BindingContext));
bindable.BindingContext = "binding";
Assert.That (bindable.GetValue (MockBindable.TextProperty), Is.EqualTo ("binding"));
}
示例9: SwitchCellSwitchChangedArgs
public void SwitchCellSwitchChangedArgs (bool initialValue, bool finalValue)
{
var template = new DataTemplate (typeof (SwitchCell));
SwitchCell cell = (SwitchCell)template.CreateContent ();
SwitchCell switchCellFromSender = null;
bool newSwitchValue = false;
cell.On = initialValue;
cell.OnChanged += (s, e) => {
switchCellFromSender = (SwitchCell)s;
newSwitchValue = e.Value;
};
cell.On = finalValue;
Assert.AreEqual (cell, switchCellFromSender);
Assert.AreEqual (finalValue, newSwitchValue);
}
示例10: SetValueAndBinding
public void SetValueAndBinding ()
{
var template = new DataTemplate (typeof (TextCell)) {
Bindings = {
{TextCell.TextProperty, new Binding ("Text")}
},
Values = {
{TextCell.TextProperty, "Text"}
}
};
Assert.That (() => template.CreateContent (), Throws.InstanceOf<InvalidOperationException> ());
}
示例11: Create
public void Create ()
{
var template = new DataTemplate (typeof (TextCell));
var content = template.CreateContent ();
Assert.IsNotNull (content);
Assert.That (content, Is.InstanceOf<TextCell> ());
}
示例12: Detail
public void Detail ()
{
var template = new DataTemplate (typeof (TextCell));
template.SetValue (TextCell.DetailProperty, "detail");
TextCell cell = (TextCell)template.CreateContent ();
Assert.That (cell.Detail, Is.EqualTo ("detail"));
}