![Avatar](https://secure.gravatar.com/avatar/f503726a792385f837535c4c9a983478.jpg?s=64&d=identicon&r=g)
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;
}