当前位置: 首页>>代码示例>>C#>>正文


C# DataTemplate.CreateContent方法代码示例

本文整理汇总了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);
		}
开发者ID:Costo,项目名称:Xamarin.Forms,代码行数:28,代码来源:BindingTests.cs

示例2: Create

		public void Create()
		{
			var template = new DataTemplate (typeof(SwitchCell));
			var content = template.CreateContent();

			Assert.That (content, Is.InstanceOf<SwitchCell>());
		}
开发者ID:Costo,项目名称:Xamarin.Forms,代码行数:7,代码来源:SwitchCellTests.cs

示例3: CreateContentType

		public void CreateContentType()
		{
			var template = new DataTemplate (typeof (MockBindable));
			object obj = template.CreateContent();

			Assert.IsNotNull (obj);
			Assert.That (obj, Is.InstanceOf<MockBindable>());
		}
开发者ID:Costo,项目名称:Xamarin.Forms,代码行数:8,代码来源:DataTemplateTests.cs

示例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));
		}
开发者ID:Costo,项目名称:Xamarin.Forms,代码行数:8,代码来源:SwitchCellTests.cs

示例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"));
		}
开发者ID:Costo,项目名称:Xamarin.Forms,代码行数:8,代码来源:SwitchCellTests.cs

示例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"));
		}
开发者ID:Costo,项目名称:Xamarin.Forms,代码行数:9,代码来源:DataTemplateTests.cs

示例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"));
		}
开发者ID:Costo,项目名称:Xamarin.Forms,代码行数:10,代码来源:DataTemplateTests.cs

示例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"));
		}
开发者ID:Costo,项目名称:Xamarin.Forms,代码行数:12,代码来源:DataTemplateTests.cs

示例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);
		}
开发者ID:Costo,项目名称:Xamarin.Forms,代码行数:20,代码来源:SwitchCellTests.cs

示例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> ());			
		}
开发者ID:Costo,项目名称:Xamarin.Forms,代码行数:12,代码来源:DataTemplateTests.cs

示例11: Create

		public void Create ()
		{
			var template = new DataTemplate (typeof (TextCell));
			var content = template.CreateContent ();

			Assert.IsNotNull (content);
			Assert.That (content, Is.InstanceOf<TextCell> ());
		}
开发者ID:Costo,项目名称:Xamarin.Forms,代码行数:8,代码来源:TextCellTests.cs

示例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"));
		}
开发者ID:Costo,项目名称:Xamarin.Forms,代码行数:8,代码来源:TextCellTests.cs


注:本文中的DataTemplate.CreateContent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。