Questions tagged [contenttemplateselector]
24 questions
22
votes
3 answers
Why would 'this.ContentTemplate.FindName' throw an InvalidOperationException on its own template?
Ok... this has me stumped. I've overridden OnContentTemplateChanged in my UserControl subclass. I'm checking that the value passed in for newContentTemplate does in fact equal this.ContentTemplate (it does) yet when I call this...
var textBox =…

Mark A. Donohoe
- 28,442
- 25
- 137
- 286
9
votes
3 answers
ContentTemplateSelector is only called one time showing always the same datatemplate
I have made a sample demo VS 2010 RC sample project, because in my production project I have the same error using MVVM.
In my sample demo project I use only Code-behind without 3rd party dependencies so you can download the demo project here and run…

msfanboy
- 5,273
- 13
- 69
- 120
8
votes
1 answer
ContentControl.ContentTemplateSelector dynamically select template
I set a ContentControl in the right of Window, and set Content binding Items (it's type is ObservableCollection). Now I want to achieve it: if there are no item, ContentControl select first DataTemplate, and add a item into items, ContentControl…

SubmarineX
- 850
- 5
- 19
- 38
5
votes
0 answers
ContentTemplateSelector does not re-evaluate on Binding changed
PREFACE
I created two different data DataTemplates to allow faster load time of my datagrid cells. One is basically a textblock, the other a more expensive UserControl. On load, the data template selector decides whether it needs to load a cheap vs.…

denis morozov
- 6,236
- 3
- 30
- 45
4
votes
1 answer
Changing ContentTemplate based on ListBox selection
I have a Listbox and a Border in a StackPanel similar to the following:

Sidebp
- 770
- 1
- 10
- 26
3
votes
1 answer
Binding a data template selector to a content control template
I would like to bind a content control to a data template selector, bind a variable to that content control and then display a different template depending on what the variable contains.
I've managed to get a Telerik DataTemplateSelector to do what…

Midimatt
- 1,114
- 2
- 17
- 35
3
votes
1 answer
DataGridCell content template selector Silverlight
I have a DataGrid with the dynamic data (collection of custom DataRows), which i get from the server. DataRow has an indexer and a property Data which returns whole data row for the binding (you'll see below)
I create each column of a DataGrid in…

lua.rasta
- 129
- 7
2
votes
1 answer
In WPF, how do I find an element in a template that's switched in via a trigger?
I have a UserControl (not a lookless custom control) which, depending on some custom state properties, swaps in various ContentTemplates, all defined as resources in the associated XAML file. In the code-behind, I need to find one of the elements…

Mark A. Donohoe
- 28,442
- 25
- 137
- 286
2
votes
1 answer
ItemsControl with multiple ItemTemplateSelector
I have this ScrollViewer:
I fill the…

imj
- 472
- 1
- 8
- 24
1
vote
0 answers
WPF: How can I retrieve the Template that was created by a ContentTemplateSelector for a specific ContentPresenter?
In my WPF app, I'm using several ContentPresenters with a special MarkupExtension that requires access to the ContentPresenter's ContentTemplate property.
The MarkupExtension works very well, except that I just found out that if a ContentPresetner…

user884248
- 2,134
- 3
- 32
- 57
1
vote
1 answer
Can't set both ContentTemplateSelector and Template properties on a DataGridColumnHeader
In short, the question title says it all. For those that want more detail, here is the crux of my problem: I need to apply a custom ControlTemplate to the DataGridColumnHeader elements in my DataGrid control, but I also need to style them…

Sheridan
- 68,826
- 24
- 143
- 183
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
2 answers
WPF ContentTemplateSelector weirdness
Goal: I wish to have an object that contains my data and have it bound to a ContentPresenter that uses a custom ContentTemplateSelector to select the proper data template for rendering in the main control.
Problem: DataTemplate does not render as…

Tyler Kendrick
- 418
- 6
- 18
0
votes
1 answer
not firing with ContentTemplateSelector
I'm trying to animate the Background Color of a Border in a DataTemplate for a DataObject when a Child Property of the DataObject changes.
The DataObject is a Class called Test with two Properties, Number and Text.
I have an ObservableCollection of…

JoeD
- 3
- 1
0
votes
0 answers
How to notify when a DataTemplate is loaded for the ContentPresenter (or ContentControl)
I know similar question was asked and as a solution it was suggested to wrap the content in a DataTemplate with Grid and use Grid_Loaded approach. But if I have let's say 10s of DataTemplates that my template selector will select one at a time based…

Tiger Galo
- 289
- 4
- 15