Questions tagged [itemtemplate]

A WPF/Xaml DataTemplate used to display each item in an ItemsControl.

A WPF/Xaml DataTemplate used to display each item in an ItemsControl.

555 questions
59
votes
2 answers

WPF Trigger for IsSelected in a DataTemplate for ListBox items

I have a listbox, and I have the following ItemTemplate for it:
TimothyP
  • 21,178
  • 26
  • 94
  • 142
57
votes
2 answers

What's the difference between ItemTemplate and ItemContainerStyle in a WPF ListBox?

In WPF Listbox, I'm confused with these 2 notions: ItemTemplate and ItemContainerStyle Can someone explain me more?
RHaguiuda
  • 3,207
  • 9
  • 37
  • 55
41
votes
2 answers

two itemtemplates for one listbox

I've got a class FruitViewModel. It describes ViewModels for ListBox items. And I've got class BananaViewModel : FruitViewModel and class AppleViewModel : FruitViewModel Fruits contains BananaViewModels…
xSeder
  • 525
  • 1
  • 5
  • 11
41
votes
1 answer

How can I make a column in a listbox in WPF the same width for all items?

I have a ListBox with an ItemTemplate consisting of a TextBlock and a ComboBox. The problem is that the width of the text inside the TextBlock is not the same for each item and the ComboBox controls are not aligned. How can I set the TextBlock in…
Julien Poulin
  • 12,737
  • 10
  • 51
  • 76
31
votes
2 answers

Binding to viewmodel from inside a datatemplate

I have multiple videos displayed they are bound with a videocollection in Mainviewmodel. Everything works fine untill I try to bind the enter command to Mainviewmodel. I Don't know the syntax for this. As it stands the binding is set to Video and…
Jeroen
  • 881
  • 1
  • 7
  • 9
18
votes
3 answers

WPF - Very basic ListBox.ItemTemplate Question

Ok, this is an embarassingly simple-looking problem, but is driving me crazy. I'm learning about DataTemplating and am trying to apply a very VERY simple ItemTemplate to a ListBox. However, when I run my app, the template is completely ignored and I…
Andy T
  • 1,901
  • 7
  • 20
  • 24
17
votes
1 answer

ItemsControl ItemTemplate Binding

In WPF4.0, I have a class that contains other class types as properties (combining multiple data types for display). Something like: public partial class Owner { public string OwnerName { get; set; } public int OwnerId { get; set;…
Wonko the Sane
  • 10,623
  • 8
  • 67
  • 92
16
votes
2 answers

What is the difference between ItemTemplate and ItemPanelTemplate?

In WPF Listbox, I'm confused with these 2 notions: ItemTemplate and ItemsPanelTemplate Can someone explain me more? Thanks John
user96547
  • 583
  • 10
  • 18
15
votes
3 answers

How to make a ListBox.ItemTemplate reusable/generic

I am trying to understand how best to extend the ListBox control. As a learning experience, I wanted to build a ListBox whose ListBoxItems display a CheckBox instead of just text. I got that working in a basic fashion using the ListBox.ItemTemplate,…
Matt Winckler
  • 2,223
  • 2
  • 23
  • 27
14
votes
1 answer

How can I get StackPanel to use an ItemTemplate?

In the following code, I tell the ComboBox to use the DataTemplate called CustomerTemplate by assigning its ItemTemplate attribute. StackPanel, however, doesn't have an ItemTemplate attribute. How can I get the StackPanel to also use…
Edward Tanguay
  • 189,012
  • 314
  • 712
  • 1,047
13
votes
4 answers

ASP.NET Repeater Template, Conditional Code for every Nth element

I'm using an asp.net repeater to create a bunch of images. The image markup is all the same so the standard is fine. However, I want to wrap K images in a div. Lets say I bind 25+ images to the repeater and I want 5 images per div.…
ckarbass
  • 3,651
  • 7
  • 34
  • 43
13
votes
2 answers

Why Does ItemsControl Not Use My ItemTemplate?

I am able to use an ItemTemplate within an ItemsControl to render items in a specific format. However, if one of the items within the ItemsControl happens to be, say, a TextBox, that TextBox is rendered rather than an instance of the ItemsTemplate.…
Drew
  • 817
  • 1
  • 11
  • 17
13
votes
2 answers

Different item template for each item in a WPF List?

I have many items inside a list control. I want each item to have a different item template depending on the type of the item. So the first item in the list is a ObjectA type and so I want it to be rendered with ItemTemplateA. Second item is a…
Phil Wright
  • 22,580
  • 14
  • 83
  • 137
11
votes
2 answers

Strange focus behavior for simple WPF ItemsControl

I'm seeing strange behavior when it comes to focus and keyboard navigation. In the example below I have a simple ItemsControl that has been templated so that it presents a list of CheckBoxes bound to the ItemsSource.
jpierson
  • 16,435
  • 14
  • 105
  • 149
10
votes
2 answers

Display multiple types from a single list in a WPF ListBox?

I have an ObservableCollection that contains two different types. I want to bind this list to a ListBox and display different DataTemplates for each type encountered. I can't figure out how to automatically switch the data templates based…
davisoa
  • 5,407
  • 1
  • 28
  • 34
1
2 3
36 37