I enumerate the list of fontfamilies and bind to combobox, the problem is when there is a font in the system that is corrupted. The whole application will crashes. Any way i
Okay, 5 years later, here's another solution:
Declare this code at the Window.Resource:
And use this Converter:
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
var list = value as IReadOnlyCollection;
if (list == null)
return DependencyProperty.UnsetValue;
var returnList = new List();
foreach (FontFamily font in list)
{
//Instantiate a TypeFace object with the font settings you want to use
Typeface ltypFace = new Typeface(font, FontStyles.Normal, FontWeights.Normal, FontStretches.Normal);
//Try to create a GlyphTypeface object from the TypeFace object
GlyphTypeface lglyphTypeFace;
if (ltypFace.TryGetGlyphTypeface(out lglyphTypeFace))
{
returnList.Add(font);
}
}
return returnList;
}
And apply the resources to the ComboBox: