Hi,
What exactly are you trying to do ? Can you provide a snippet ?
Here's a test :
What exactly are you trying to do ? Can you provide a snippet ?
Here's a test :
In XAML :
<Grid>
<xctk:PropertyGrid x:Name="_propertyGrid" />
</Grid>
In Code-Behind :
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
_propertyGrid.SelectedObject = new MyTest()
{
EditorFont = new Font()
{
MyFontFamily = new FontFamily("Stencil"),
Size = 13
}
};
}
}
public class MyTest
{
// Property in class
private Font _editorFont;
[Category( "Workspace" ),
Description( "The font used for editing documents." ),
DisplayName( "Editor Font" ),
ExpandableObject()]
public Font EditorFont
{
get
{
return _editorFont;
}
set
{
_editorFont = value;
}
}
}
[TypeConverter(typeof(FontConverter))]
public class Font
{
public FontFamily MyFontFamily
{
get;
set;
}
public int Size
{
get;
set;
}
}
public class FontConverter : TypeConverter
{
public FontConverter()
{
}
public override bool CanConvertTo( ITypeDescriptorContext context, Type destinationType )
{
return ( destinationType == typeof( string ) )
|| base.CanConvertTo( context, destinationType );
}
public override bool CanConvertFrom( ITypeDescriptorContext context, Type sourceType )
{
return ( sourceType == typeof( string ) )
|| base.CanConvertFrom( context, sourceType );
}
public override object ConvertTo( ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType )
{
if( ( destinationType == typeof( string ) ) )
{
return "My Font";
}
return base.ConvertTo( context, culture, value, destinationType );
}
public override object ConvertFrom( ITypeDescriptorContext context, CultureInfo currentCulture, object value )
{
if( value != null && ( value is string ) )
{
return new Font();
}
return base.ConvertFrom( context, currentCulture, value );
}
}