RT,就是想用RibbonComboBox显示系统字体,和Word2010里面一样,具体XAML代码:
资源中添加:
<Grid.Resources>
<CollectionViewSource x:Key="sysFonts" Source="{x:Static Fonts.SystemFontFamilies}" />
</Grid.Resources>
RibbonComboBox使用如下:
<r:RibbonComboBox x:Name="ChooseFontComboBox"
ItemsSource="{Binding Source={StaticResource sysFonts}}">
<r:RibbonComboBox.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel>
</StackPanel>
</ItemsPanelTemplate>
</r:RibbonComboBox.ItemsPanel>
<r:RibbonComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding}" FontFamily="{Binding}" FontSize="16"></TextBlock>
</DataTemplate>
</r:RibbonComboBox.ItemTemplate>
</r:RibbonComboBox>
能显示系统字体,但是不显示滚动条,也无法使用滚轮滚动,也就是说,屏幕有多大就显示多少项目,很郁闷,查了很多网站,试了很多种方法都没用,特此请教……
先谢谢了……
资源中添加:
<Grid.Resources>
<CollectionViewSource x:Key="sysFonts" Source="{x:Static Fonts.SystemFontFamilies}" />
</Grid.Resources>
RibbonComboBox使用如下:
<r:RibbonComboBox x:Name="ChooseFontComboBox"
ItemsSource="{Binding Source={StaticResource sysFonts}}">
<r:RibbonComboBox.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel>
</StackPanel>
</ItemsPanelTemplate>
</r:RibbonComboBox.ItemsPanel>
<r:RibbonComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding}" FontFamily="{Binding}" FontSize="16"></TextBlock>
</DataTemplate>
</r:RibbonComboBox.ItemTemplate>
</r:RibbonComboBox>
能显示系统字体,但是不显示滚动条,也无法使用滚轮滚动,也就是说,屏幕有多大就显示多少项目,很郁闷,查了很多网站,试了很多种方法都没用,特此请教……
先谢谢了……
只能看人家ribbon的例子了换个普通 combobox行不
不过,看来也只能如此了……
至于Ms自带的Ribbon的例子,里面的Ribboncombobox倒是很完美,但是代码太复杂了,而且使用了MVVM,恕我愚钝,实在看不出来和我的有什么不一样,为什么就不能完美显示?
奇怪的就是,所有XAML代码都没改,只是换成了普通的ComboBox,为何问题就没有了?郁闷……