mirror of
https://github.com/holgerb83/ModernWpfPlayground.git
synced 2025-06-30 09:40:52 +02:00
Many new plays
This commit is contained in:
39
PropertyPresenter2/PropertyDataTemplateSelector.cs
Normal file
39
PropertyPresenter2/PropertyDataTemplateSelector.cs
Normal file
@ -0,0 +1,39 @@
|
||||
using System;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace LsBricks.Controls
|
||||
{
|
||||
/// <summary>
|
||||
/// Selects the right template on base of value-type.
|
||||
/// </summary>
|
||||
public class PropertyDataTemplateSelector : DataTemplateSelector
|
||||
{
|
||||
/// <summary>
|
||||
/// Default data template. (currently Textbox)
|
||||
/// </summary>
|
||||
public DataTemplate DefaultDataTemplate { private get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Data template for boolean. (currently Checkbox)
|
||||
/// </summary>
|
||||
public DataTemplate BooleanDataTemplate { private get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Data template for enums. (currently Combobox)
|
||||
/// </summary>
|
||||
public DataTemplate EnumComboBoxDataTemplate { private get; set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public override DataTemplate SelectTemplate(object item, DependencyObject container)
|
||||
{
|
||||
return item switch
|
||||
{
|
||||
bool _ => BooleanDataTemplate,
|
||||
Enum _ => EnumComboBoxDataTemplate,
|
||||
UIElement _ => null,
|
||||
_ => DefaultDataTemplate
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user