tags:

views:

120

answers:

1

i have created a RibbonGallery/ComboBox to display a list of installed fonts.

alt text

but sometimes after entering say "V" this is what i get

alt text

look at the text in the menu.

[Font Family: Name=...

why is that happening.

code

// xaml
<ribbon:RibbonComboBox Label="Gallery">
    <ribbon:RibbonGallery SelectedValue="ABC" SelectedValuePath="Content" MaxColumnCount="1">
        <ribbon:RibbonGalleryCategory x:Name="fontsMenu" />
    </ribbon:RibbonGallery>
</ribbon:RibbonComboBox>

// code behind
InstalledFontCollection col = new InstalledFontCollection();
fontsMenu.ItemsSource = col.Families;
fontsMenu.DisplayMemberPath = "Name";
A: 

That's how FontFamily.ToString() implemented and thats exactly what we have displayed:

  public override string ToString()
   {
      return string.Format(CultureInfo.CurrentCulture, "[{0}: Name={1}]", new object[] {  base.GetType().Name, this.Name });
    }

You definitely need to set some DisplayMemberPath to "Name" and you already have one on RibbonGalleryCategory but now i'm curious - shouldnt it be set on RibbonGallery or even RibbonComboBox? Frankly speaking i haven't used wpf ribbon controls yet - all i can suggest is just assumption.

Hope this'll help :)

ProfyTroll