datatemplateselector

How to use DataTemplateSelector with ContentControl to display different controls based on the view-model?

让人想犯罪 __ 提交于 2019-12-01 12:32:40
问题 I want to create a simple window that would display different controls ( SpinEdit or TextEdit ) based on the view-model that is selected. I have the code and logic behind it done already, what is left is displaying the control ( SpinEdit or TextEdit ) itself. XAML: <dx:DXWindow.Resources> <DataTemplate x:Key="DataTemplate_Value"> <dxe:SpinEdit Height="23" MinWidth="200" Width="Auto" Text="{Binding Path=Value, Mode=TwoWay}" Mask="{Binding Mask, Mode=OneWay}" MaxLength="{Binding Path

How to properly reference a class from XAML [closed]

人走茶凉 提交于 2019-11-30 21:18:32
OK, this is a super super noob question, one that I'm almost embarrassed to ask... I want to reference a class in my XAML file. It's a DataTemplateSelector for selecting the right edit template for a DataGrid column. Anyway, I've written the class into my code behind, added the local namespace to the top of top of the XAML, but when I try to reference the class from the XAML, it tells me the class does not exist in the local namespace. I must be missing something really really simple but I just can't understand it... Here's my code. XAML: <Window xmlns="http://schemas.microsoft.com/winfx/2006

ContentControl with DataTemplateSelector - help needed

不羁岁月 提交于 2019-11-30 20:32:09
I got an enoying problem... Maybe someone can (please!) help. I am using a model that has and enumeration of types and a property that should hold UI models for each selected type from enumeration: Let's define them like: class ViewModel { Types selectedType{get;set;} UiModelBase editedModel{get;set;} } I want to have a content control that use datatemplateselector to change his view each time I change the selectedType. <ListBox x:Name="RuleTypeList" ItemsSource="{Binding Source={StaticResource Types}}" SelectedItem="{Binding Path=selectedType}"/> <!--Content control--> <ContentControl

How to properly reference a class from XAML [closed]

自古美人都是妖i 提交于 2019-11-30 05:31:22
问题 This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. Closed 7 years ago . OK, this is a super super noob question, one that I'm almost embarrassed to ask... I want to reference a class in my XAML file. It's a

ContentControl with DataTemplateSelector - help needed

心已入冬 提交于 2019-11-30 05:01:32
问题 I got an enoying problem... Maybe someone can (please!) help. I am using a model that has and enumeration of types and a property that should hold UI models for each selected type from enumeration: Let's define them like: class ViewModel { Types selectedType{get;set;} UiModelBase editedModel{get;set;} } I want to have a content control that use datatemplateselector to change his view each time I change the selectedType. <ListBox x:Name="RuleTypeList" ItemsSource="{Binding Source=

WPF: Reapply DataTemplateSelector when a certain value changes

安稳与你 提交于 2019-11-28 11:53:06
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> list = item as GroupList<Person>; if (list != null && !list.IsLeaf) return GroupTemplate; return

Explicitly refresh DataTemplate from a DataTemplateSelector?

血红的双手。 提交于 2019-11-28 10:49:24
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 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 and then back again -- I think that would work but haven't tested it -- but this is pretty ugly!) If there

ControlTemplate with DataTrigger Vs. DataTemplate with DataTemplateSelector

China☆狼群 提交于 2019-11-28 07:01:37
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> <DataTrigger Binding="{Binding Path=EditorType}" Value="{x:Static view:EditorType.Text}"> <Setter Property=

How to trigger DataTemplateSelector when property changes?

牧云@^-^@ 提交于 2019-11-27 18:31:53
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 DataTemplateSelector when the property is changed and change ContentPresenter DataTemplate. Any suggestions? Threre are

Combining DataTemplates at runtime

亡梦爱人 提交于 2019-11-27 08:52:23
问题 I have a ListBox that presents a databound list of objects via its ItemSource. Because each object has special display needs I’m defining an ItemTemplateSelector that returns the appropriate DataTemplate depending on the object. That all works without a hitch. The DataTemplates for each object follow a common formula, but contains custom elements in the middle. For example: <DataTemplate x:Key="collectibleTemplate"> <Grid> <Grid.RowDefinitions> <RowDefinition Height="Auto" /> </Grid