I was playing around the the PropertyGrid and I created a simple project to test the WPF PropertyGrid. Using a standard Windows.Forms PropertyGrid and the System.Drawing.Font object you can simply create a property the the Font type and the PropertyGrid displays it using the default TypeEditor. With the WPF PropertyGrid in the Toolkit, this was not the case.
My original question was whether or not I needed to create my own TypeEditor(s) for such objects. It is also the only way I could use a font with the control. Sorry for the lengthy code.
The preferences class:
Regards,
Mark
My original question was whether or not I needed to create my own TypeEditor(s) for such objects. It is also the only way I could use a font with the control. Sorry for the lengthy code.
The preferences class:
[Serializable]
public class Preferences
{
private WpFFont _editorFont = new WpFFont(
new FontFamily("Segoe UI"),
9.75F, FontWeights.Normal,
FontStyles.Normal, FontStretches.Normal );
[Category("Editor"),
DisplayName("Font"),
Description("The font used for the editor.")]
public WpFFont EditorFont
{
get { return _editorFont; }
set { _editorFont = value; }
}
}
The custom font class: [Serializable, ExpandableObject]
public class WpFFont
{
private FontFamily _family;
private FontStyle _style;
private FontStretch _stretch;
private FontWeight _weight;
private double _size;
public FontFamily Family
{
get { return _family; }
set { _family = value; }
}
public FontWeight Weight
{
get { return _weight; }
set { _weight = value; }
}
public FontStretch Stretch
{
get { return _stretch; }
set { _stretch = value; }
}
public double FontSize
{
get { return _size; }
set { _size = value; }
}
public FontStyle Style
{
get { return _style; }
set { _style = value; }
}
public WpFFont() { }
public WpFFont( FontFamily family, double fontSize, FontWeight weight, FontStyle style, FontStretch stretch )
{
this.Family = family;
this.FontSize = fontSize;
this.Weight = weight;
this.Style = style;
this.Stretch = stretch;
}
public override string ToString()
{
return string.Format( "{0},{1},{2},{3},{4}", Family, FontSize, Weight, Style, Stretch );
}
}
I have written help documentation myself and it can be a arduous task. Too bad there is not better documentation for the Toolkit.Regards,
Mark