WPF:数据绑定和显示成员路径
我创建了一个 RibbonGallery/ComboBox 来显示已安装字体的列表。
但有时输入后说“V”,这就是我得到的
查看菜单中的文本。
[Font Family: Name=...
为什么会发生这种情况。
代码
// 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";
i have created a RibbonGallery/ComboBox
to display a list of installed fonts.
but sometimes after entering say "V" this is what i get
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";
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这就是 FontFamily.ToString() 的实现方式,这正是我们所显示的:
您肯定需要将一些 DisplayMemberPath 设置为“Name”,并且您已经在 RibbonGalleryCategory 上设置了一个,但现在我很好奇 - 不应该在 RibbonGallery 甚至 RibbonComboBox 上设置它?坦率地说,我还没有使用过 wpf 功能区控件 - 我所能建议的只是假设。
希望这会有所帮助:)
That's how FontFamily.ToString() implemented and thats exactly what we have displayed:
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 :)