Code from RichTextBoxExtended.cs
private void OnFontFamilyCanExecute(object sender, CanExecuteRoutedEventArgs e) {
FontFamilyValueCommandParameter parameter = e.Parameter as FontFamilyValueCommandParameter;
if ((parameter != null) && (!this.IsPreviewModeActive)) {
parameter.UpdatedValue = this.SelectionFontFamily;
parameter.Handled = true;
}
e.CanExecute = true;
}
My extension method
public static bool SetFontComboBoxValue(this FontFamilyComboBox comboBox, string font)
{
int i = 0;
foreach (ComboBoxItem item in comboBox.Items)
{
if (((FontFamily)item.Content).Source == font)
{
break;
}
i++;
}
bool foundValue = i < comboBox.Items.Count;
if (foundValue)
{
comboBox.SelectedIndex = i;
}
return foundValue;
}