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


C# DataTemplate类代码示例

本文整理汇总了C#中DataTemplate的典型用法代码示例。如果您正苦于以下问题:C# DataTemplate类的具体用法?C# DataTemplate怎么用?C# DataTemplate使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


DataTemplate类属于命名空间,在下文中一共展示了DataTemplate类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: CellTypeList

		// TODO Add gallerys for ViewCell, ListView and TableView
		public CellTypeList ()
		{
			var itemList = new List<CellNavigation> {
				new CellNavigation ("TextCell List", new TextCellListPage ()),
				new CellNavigation ("TextCell Table", new TextCellTablePage ()),
				new CellNavigation ("ImageCell List", new ImageCellListPage ()),
				new CellNavigation ("ImageCell Url List", new UrlImageCellListPage()),
				new CellNavigation ("ImageCell Table", new ImageCellTablePage ()),
				new CellNavigation ("SwitchCell List", new SwitchCellListPage ()),
				new CellNavigation ("SwitchCell Table", new SwitchCellTablePage ()),
				new CellNavigation ("EntryCell List", new EntryCellListPage ()),
				new CellNavigation ("EntryCell Table", new EntryCellTablePage ()),
				new CellNavigation ("ViewCell Image url table", new UrlImageViewCellListPage())
			};
			
			ItemsSource = itemList;

			var template = new DataTemplate (typeof (TextCell));
			template.SetBinding (TextCell.TextProperty, new Binding ("CellType"));

			ItemTemplate = template;
			ItemSelected += (s, e) => {
				if (SelectedItem == null)
					return;

				var cellNav = (CellNavigation) e.SelectedItem;
				Navigation.PushAsync (cellNav.Page);
				SelectedItem = null;
			};
		}		
开发者ID:Costo,项目名称:Xamarin.Forms,代码行数:31,代码来源:CellTypeList.cs

示例3: ViewPresenter

            public ViewPresenter(DataTemplate viewTemplate, DataTemplateSelector viewTemplateSelector) {
                ContentTemplate = viewTemplate;
#if !SILVERLIGHT
                ContentTemplateSelector = viewTemplateSelector;
#endif
                Loaded += ViewPresenter_Loaded;
            }
开发者ID:ruisebastiao,项目名称:DevExpress.Mvvm.Free,代码行数:7,代码来源:ViewHelper.cs

示例4: CreateFallbackViewTemplate

 internal static DataTemplate CreateFallbackViewTemplate(string errorText) {
     var factory = new FrameworkElementFactory(typeof(FallbackView));
     factory.SetValue(FallbackView.TextProperty, errorText);
     var res = new DataTemplate() { VisualTree = factory };
     res.Seal();
     return res;
 }
开发者ID:sk8tz,项目名称:DevExpress.Mvvm.Free,代码行数:7,代码来源:IViewLocator.cs

示例5: CultureInfoEditor

        /// <summary>
        /// Default constructor builds a ComboBox inline editor template.
        /// </summary>
        public CultureInfoEditor()
        {
            // not using databinding here because Silverlight does not support
            // the WPF CultureConverter that is used by Blend.
            FrameworkElementFactory comboBox = new FrameworkElementFactory(typeof(ComboBox));
            comboBox.AddHandler(
                ComboBox.LoadedEvent,
                new RoutedEventHandler(
                    (sender, e) =>
                    {
                        _owner = (ComboBox)sender;
                        _owner.SelectionChanged += EditorSelectionChanged;
                        INotifyPropertyChanged data = _owner.DataContext as INotifyPropertyChanged;
                        if (data != null)
                        {
                            data.PropertyChanged += DatacontextPropertyChanged;
                        }
                        _owner.DataContextChanged += CultureDatacontextChanged;
                    }));

            comboBox.SetValue(ComboBox.IsEditableProperty, false);
            comboBox.SetValue(ComboBox.DisplayMemberPathProperty, "DisplayName");
            comboBox.SetValue(ComboBox.ItemsSourceProperty, CultureInfo.GetCultures(CultureTypes.SpecificCultures));
            DataTemplate dt = new DataTemplate();
            dt.VisualTree = comboBox;

            InlineEditorTemplate = dt;
        }
开发者ID:modulexcite,项目名称:SilverlightToolkit,代码行数:31,代码来源:CultureInfoEditor.cs

示例6: 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

示例7: MyDataTemplateSelector

			public MyDataTemplateSelector()
			{
				_1Template = new DataTemplate(() =>
				{
					return new TextCell { Text = Success1 };
				});

				_2Template = new DataTemplate(() =>
				{
					return new TextCell { Text = Success2 };
				});

				_3Template = new DataTemplate(() =>
				{
					return new TextCell { Text = Success3 };
				});

				_4Template = new DataTemplate(() =>
				{
					return new TextCell { Text = Success4 };
				});

				_5Template = new DataTemplate(() =>
				{
					return new TextCell { Text = Success5 };
				});

				_6Template = new DataTemplate(() =>
				{
					return new TextCell { Text = Success6 };
				});
			}
开发者ID:ytn3rd,项目名称:Xamarin.Forms,代码行数:32,代码来源:Bugzilla42277.cs

示例8: 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

示例9: 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

示例10: 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

示例11: EmptyEditor

 /// <summary>
 /// Default constructor builds the default TextBox inline editor template.
 /// </summary>
 public EmptyEditor()
 {
     FrameworkElementFactory textBox = new FrameworkElementFactory(typeof(TextBox));
     textBox.SetValue(TextBox.IsReadOnlyProperty, true);
     DataTemplate dt = new DataTemplate();
     dt.VisualTree = textBox;
     InlineEditorTemplate = dt;
 }
开发者ID:yan122725529,项目名称:SqlComPare_Mvvm,代码行数:11,代码来源:EmptyEditor.cs

示例12: CreateView

 public static object CreateView(IViewLocator viewLocator, string documentType, DataTemplate viewTemplate = null, DataTemplateSelector viewTemplateSelector = null) {
     if(documentType == null && viewTemplate == null & viewTemplateSelector == null)
         throw new InvalidOperationException(string.Format("{0}{1}To learn more, see: {2}", Error_CreateViewMissArguments, System.Environment.NewLine, HelpLink_CreateViewMissArguments));
     if(viewTemplate != null || viewTemplateSelector != null) {
         return new ViewPresenter(viewTemplate, viewTemplateSelector);
     }
     IViewLocator actualLocator = viewLocator ?? (ViewLocator.Default ?? ViewLocator.Instance);
     return actualLocator.ResolveView(documentType);
 }
开发者ID:LINDAIS,项目名称:DevExpress.Mvvm.Free,代码行数:9,代码来源:ViewHelper.cs

示例13: 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

示例14: 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

示例15: PrepareContainerForItem

        public void PrepareContainerForItem(object item, DataTemplate template)
        {
            if (!ContainsValue(ContentTemplateProperty) && !ContainsValue(ContentTemplateSelectorProperty))
            {
                this.ContentTemplate = template;
                isContainerTemplate = true;
            }

            Content = item;
        }
开发者ID:diab0l,项目名称:Granular,代码行数:10,代码来源:ContentPresenter.cs


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