Questions tagged [itemtemplateselector]

Gets or sets the custom logic for choosing a template used to display each item.

You use the ItemTemplate to specify the visualization of the data objects. If you have more than one template defined and want to supply logic to return a template to use, then you use this property. Note that this property is ignored if ItemTemplate is set. The ItemsControl provides great flexibility for visual customization and provides many styling and templating properties. Use the ItemContainerStyle property or the ItemContainerStyleSelector property to set a style to affect the appearance of the elements that contain the data items. For example, for ListBox, the generated containers are ListBoxItem controls; for ComboBox, they are ComboBoxItem controls. To affect the layout of the items, use the ItemsPanel property. If you are using grouping on your control, you can use the GroupStyle or GroupStyleSelector property.

For more information, see Data Templating Overview.

27 questions
5
votes
1 answer

MvvmCross : dynamic item template selection for MvxListView

If I have a view with the following MvxListView definition:
Klaus Nji
  • 18,107
  • 29
  • 105
  • 185
4
votes
2 answers

ItemTemplateSelector in WPF Datagrid with AutoGenerateColumns

In our data grid we're using an ItemTemplateSelector to switch between two data templates based on the data bound to a particular cell. As the number of columns depends on the current data set we're using AutoGenerateColumns in our DataGrid. It…
cacau
  • 3,606
  • 3
  • 21
  • 42
4
votes
1 answer

WPF ItemTemplateSelector to single item

ItemTemplateSelector is applied to collections of objects - ItemsControl for example. Is there the same functionality for single items controls? I want to choose a data template taking in consideration a value inside an object. I can do this for…
Louro
  • 1,413
  • 4
  • 21
  • 27
4
votes
2 answers

WPF treeview ItemTemplate and ItemTemplateSelector are ignored

In my application, I have been getting this error each time the treeView loads it's items. This error makes my application slow on load and takes at least two minutes to load. The error is: System.Windows.Data Error: 26 : ItemTemplate and…
Rui
  • 387
  • 7
  • 22
3
votes
1 answer

WPF Treeview HierarchicalDataTemplate ItemTemplateSelector

I am trying to create a simple 2 level Treeview in WPF (MVVM approach). For my first level I have a standard datatemplate, for my second level I want to use a Template Selector so that I can change the appearance of each item based on one of its…
Krishna
  • 1,956
  • 13
  • 25
3
votes
1 answer

LongListSelector different item template for first and last item

Im writing my Windows phone 8 app which uses LongListSelector to display some data. How to set different item template for first and last item in LongListSelector? Basically I just want to display same information in every item but use little…
2
votes
2 answers

How to get ItemTemplateSelector to work in WPF

In a WPF project I have a ComboBox to select from different objects. Using an ItemsControl and it's ItemTemplateSelector I am trying to show different UI for the ComboBox selection based on a property of the object. So, in the example below we pick…
Cleve
  • 1,273
  • 1
  • 13
  • 26
1
vote
0 answers

UWP : Worries with itemtemplateselector with GridView

I have a problem on an UWP project I'm currently working on : I have a viewmodel like this : public class HomePageViewModel : INotifyPropertyChanged { public event PropertyChangedEventHandler PropertyChanged; public…
1
vote
1 answer

Both 'ItemTemplate' and 'ItemTemplateSelector' are set; 'ItemTemplateSelector' will be ignored

Following this question, I have another question about TreeView. What I already have is a TreeViewwith HierarchicalDataTemplate, in which I can change the HierarchicalDataTemplate of level2 (like explained in the question and the answer). What I…
1
vote
1 answer

How to force re-selection of DataTemplateSelector

I am using a DataTemplateSelector in UWP on a ListBox and I want to force a re-selection of the DataTemplate for an existing ListBoxItem. The only way I can get it to work is to remove the item from the bound collection and then re-add the item.…
AQuirky
  • 4,691
  • 2
  • 32
  • 51
1
vote
2 answers

relative panel / grid cannot align the horizontal alignment in item template selector

I am working on a chat application. The chat page consists of a itemTemplateSelector which aligns the text to right end/left end according to the sender by checking a bool value. here is the code
KartheekJ
  • 65
  • 9
1
vote
1 answer

WPF TabControl - Do I need an ItemTemplateSelector *and* a ContentTemplateSelector?

So I have as the main user control in my WPF app a TabControl that will support several different views (basically forms for data entry) and their underlying view models (basically ORM mappings.) I built a ContentTemplateSelector to throw out the…
Kyle Hale
  • 7,912
  • 1
  • 37
  • 58
1
vote
0 answers

WPF TreeView ItemTemplateSelector not working

I have a TreeView and two HierachicalDataTemplates: one with DataType="{x:Type local:Department}" x:Key="D" and one with DataType="{x:Type local:Employee}" x:Key="E" if I leave out the x:keys it works (because Templates are picked up automatically),…
1
vote
2 answers

Auto refresh ItemTemplateSelector

I have ItemsControl with multi DataTemplate and use ItemTemplateSelector to chose appropriate DataTemplate of each item of ItemsSource. I want to binding ItemTemplateSelector to TemplateType dependency property of item. and each time TemplateType…
mehdi lotfi
  • 11,194
  • 18
  • 82
  • 128
0
votes
0 answers

How can I re-invoke OnSelectTemplate for a .Net MAUI CollectionView to return different templates should the window size change?

I have a .Net MAUI page that lists news stories; the list typically contains 10-100 items. To add visual variety, every 10th item uses a "big photo" DataTemplate while the others use a "regular" DataTemplate. This is handled with a…
1
2