datatemplateselector

WPF: Reapply DataTemplateSelector when a certain value changes

纵饮孤独 提交于 2019-11-27 06:34:14
问题 So here is the XAML that I have: <ItemsControl ItemsSource="{Binding Path=Groups}" ItemTemplateSelector="{Binding RelativeSource={RelativeSource AncestorType=Window}, Path=ListTemplateSelector}"/> Here is my ListTemplateSelector class: public class ListTemplateSelector : DataTemplateSelector { public DataTemplate GroupTemplate { get; set; } public DataTemplate ItemTemplate { get; set; } public override DataTemplate SelectTemplate(object item, DependencyObject container) { GroupList<Person>

How to trigger DataTemplateSelector when property changes?

柔情痞子 提交于 2019-11-27 04:18:14
问题 I have ContentPresenter with DataTemplateSelector: ... public override DataTemplate SelectTemplate(object item, DependencyObject container) { var model = item as ItemControlViewModel; if (model.CurrentStatus == PrerequisitesStatus.Required) { return RequiredTemplate; } if (model.CurrentStatus == PrerequisitesStatus.Completed) { return FinishedTemplate; } ... return InProgressTemplate; } When CurrentStatus is changed, OnPropertyChanged is called. I need somehow to trigger this

Explicitly refresh DataTemplate from a DataTemplateSelector?

混江龙づ霸主 提交于 2019-11-27 03:49:40
问题 I set up a ContentControl.DataTemplateSelector to my desired one. I want that according to a command or whatever, call the ContentControl to reselect the template from the selector by either xaml or code. Thank 回答1: I'm not aware of any (non-kludgy) way to do this: the DataTemplateSelector is called when WPF needs to select the template, and that's a one-off decision as far as WPF is concerned. (You can kludge it by making WPF think the content has changed, e.g. by setting the content to null

Change Data template dynamically

偶尔善良 提交于 2019-11-27 03:42:16
I have a item control which is bound to Tasks. Each task has task state. I have defined different data templates for each task state, and also data template selector. Problem is that I am not able to figure out how to trigger data template selector when task state is changed dynamically. I want to know how to use data triggers together with data templates. If this will not work out, i will explore other alternatives such as 1. Attached Property bound to task state. Any change will dynamically set data template. 2. Visual State Manager A DataTemplateSelector does not respond to PropertyChange

ControlTemplate with DataTrigger Vs. DataTemplate with DataTemplateSelector

我的未来我决定 提交于 2019-11-27 01:40:19
问题 I have a generic control which displays an editor based on the type property inside a ViewModel. Currently it's implemented using Control , ControlTemplate and DataTrigger like this - <Control x:Name="MainControl" Grid.Column="1" TargetUpdated="OnTargetUpdated"> <Control.Style> <Style> <Style.Triggers> <DataTrigger Binding="{Binding Path=EditorType}" Value="{x:Static view:EditorType.Bool}"> <Setter Property="Control.Template" Value="{StaticResource boolTemplate}" /> </DataTrigger>

Change Data template dynamically

本小妞迷上赌 提交于 2019-11-26 10:29:37
问题 I have a item control which is bound to Tasks. Each task has task state. I have defined different data templates for each task state, and also data template selector. Problem is that I am not able to figure out how to trigger data template selector when task state is changed dynamically. I want to know how to use data triggers together with data templates. If this will not work out, i will explore other alternatives such as 1. Attached Property bound to task state. Any change will dynamically