开发者

WPF: Data binding & Display member path

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

WPF: Data binding & Display member path

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

WPF: Data binding & Display member path

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:Ribbo开发者_运维知识库nGallery>
</ribbon:RibbonComboBox>

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


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 :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜