Top "Datatemplate" questions

Data templating is a feature of WPF and Xamarin.

WPF: How to bind to only one item in a collection, not using ItemsControl since I don't want to display all of them

I have this requirement, that I have a collection of items (ObservableCollection), but I only want to display the first …

wpf xaml data-binding datatemplate
Styling WPF ComboBox items

I have a very simple WPF application which displays a ComboBox which binds to a list of classes which represent …

c# wpf combobox datatemplate styling
Create DataTemplate in code behind

How do i add controls to datatemplates programmatically? For Example. Below I've created TextBlock and DataTemplate. TextBlock text = new TextBlock(); …

c# dynamic datatemplate code-behind
Find a WPF element inside DataTemplate in the code-behind

I have a data-template <Window.Resources> <DataTemplate x:Key="BarChartItemsTemplate"> <Border Width="385" Height="50"> <…

c# wpf xaml datatemplate bar-chart
How to Bind To Data within a Datatemplate of a ContentControl

I have the following simplified Example: <Window x:Class="TemplateBinding.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" …

wpf data-binding datatemplate resourcedictionary contentcontrol
Binding a WPF Button CommandParameter to the Button itself in DataTemplate

I have a DataTemplate that represents AppBar buttons that I declare through a collection of custom AppBarCommand objects. public AppBarCommand(…

c# wpf binding datatemplate commandparameter
Silverlight 3: ListBox DataTemplate HorizontalAlignment

I have a ListBox with it's ItemTemplate bound to a DataTemplate. My problem is I cannot get the elements in …

silverlight listbox datatemplate controltemplate
Binding to a viewmodel property in a DataTemplate

I'm fairly new to XAML but enjoying learning it. The thing I'm really struggling with is binding a property to …

wpf xaml properties binding datatemplate
How do I create a datatemplate with content programmatically?

I want to do the following at runtime in code: <DataTemplate x:Key="lightGreenRectangle"> <Rectangle Fill="LightGreen"/&…

wpf telerik datatemplate
Using ItemTemplate for a TreeView when adding items in code

I'm adding TreeViewItems manually in code behind and would like to use a DataTemplate to display them but can't figure …

wpf xaml treeview datatemplate itemtemplate