Hi,
In the PropertyGrid, there is the "EditorDefinitions" property that let's you set the Editor you want for specific properties. You can say for example : all the bool properties will have a red Background, all the Dates will have a specific format, a property named "MyString" will use a ComboBox where you set the source, a property named "MySpecialProp" will use a specific DataTemplate...
Please have a look at the samples :
-PropertyGrid/Editors/EditorTemplateDefinition
-PropertyGrid/Editors/More Editors Definitions
from the "Live Explorer app" available on this page : https://wpftoolkit.codeplex.com/
The Xceed DataGrid can also set specific editors for specific columns. So if a Column is of type string, the editor can be of type DatePicker or ComboBox when used with a Converter. Here's an example :
In the PropertyGrid, there is the "EditorDefinitions" property that let's you set the Editor you want for specific properties. You can say for example : all the bool properties will have a red Background, all the Dates will have a specific format, a property named "MyString" will use a ComboBox where you set the source, a property named "MySpecialProp" will use a specific DataTemplate...
Please have a look at the samples :
-PropertyGrid/Editors/EditorTemplateDefinition
-PropertyGrid/Editors/More Editors Definitions
from the "Live Explorer app" available on this page : https://wpftoolkit.codeplex.com/
The Xceed DataGrid can also set specific editors for specific columns. So if a Column is of type string, the editor can be of type DatePicker or ComboBox when used with a Converter. Here's an example :
<Window.Resources>
<local:MyConverter x:Key="MyConverter" />
<xcdg:CellEditor x:Key="ValueEditor">
<xcdg:CellEditor.EditTemplate>
<DataTemplate>
<xctk:DateTimePicker Value="{xcdg:CellEditorBinding Converter={StaticResource MyConverter}}"
Format="ShortDate" />
</DataTemplate>
</xcdg:CellEditor.EditTemplate>
</xcdg:CellEditor>
</Window.Resources>
<Grid>
<StackPanel>
<xcdg:DataGridControl x:Name="_dataGrid"
AutoCreateColumns="False">
<xcdg:DataGridControl.Columns>
<xcdg:Column FieldName="Setting"
Title="My Settings" />
<xcdg:Column FieldName="Value"
Title="My Values"
CellEditor="{StaticResource ValueEditor}"/>
<xcdg:Column FieldName="Description"
Title="My Descriptions" />
</xcdg:DataGridControl.Columns>
</xcdg:DataGridControl>
</StackPanel>
</Grid>
and the Code-behind : public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
_dataGrid.ItemsSource = new List<MyData>()
{
new MyData(){ Setting = "Setting 1", Value = "2010/12/15", Description = "Desc1" },
new MyData(){ Setting = "Setting 2", Value = "2008/09/17", Description = "Desc2" },
new MyData(){ Setting = "Setting 3", Value = "2005/06/24", Description = "Desc3" },
new MyData(){ Setting = "Setting 4", Value = "2013/11/14", Description = "Desc4" },
};
}
}
public class MyData
{
public string Setting
{
get;
set;
}
public string Value
{
get;
set;
}
public string Description
{
get;
set;
}
}
public class MyConverter : IValueConverter
{
public object Convert( object value, Type targetType, object parameter, CultureInfo culture )
{
DateTime dateTime = DateTime.Parse( (string)value );
return dateTime;
}
public object ConvertBack( object value, Type targetType, object parameter, CultureInfo culture )
{
DateTime dateTime = (DateTime)value;
return dateTime.ToShortDateString();
}
}
You can also have a look at the samples in section "EditingData" when you "run Demo" of the Xceed DataGrid from this page : http://xceed.com/Grid_WPF_Demo.html