WPF: List of fonts in combo

  • Thread starter Thread starter moondaddy
  • Start date Start date
M

moondaddy

I have a list of fonts in a combo. how to I make each item in the list use
that font as it's (the item's) style similar to viewing a list of fonts in
Word?

<ComboBox Grid.Row="0" Grid.Column="1" x:Name="Font"
VerticalAlignment="Top" Height="24" IsSynchronizedWithCurrentItem="True"
ItemsSource="{x:Static Fonts.SystemFontFamilies}"/>


Thanks.
 
Hi George,

To get what you want, you need to implement a DataTemplate for the items of
the ComboBox control.

The following is a sample:

<ComboBox ItemsSource="{x:Static Fonts.SystemFontFamilies}">
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding}" FontFamily="{Binding}"/>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>

Hope this helps.
If you have any question, please feel free to let me know.

Sincerely,
Linda Liu
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
Rather than binding the item source, just fill the box in the owner's
loaded event by looping through all the fonts in
Fonts.SystmFontFamilies and making the ComboBoxItem.FontFamily match
the font name you put in the item.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top