By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,899 Members | 1,336 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,899 IT Pros & Developers. It's quick & easy.

WPF: List of fonts in combo

P: n/a
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.

--
mo*******@newsgroup.nospam
Jul 7 '08 #1
Share this Question
Share on Google+
3 Replies


P: n/a
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:
ms****@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.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/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Jul 8 '08 #2

P: n/a
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.
Jul 8 '08 #3

P: n/a
Thanks Linda, That was totaly perfect.

"Linda Liu[MSFT]" <v-****@online.microsoft.comwrote in message
news:TW**************@TK2MSFTNGHUB02.phx.gbl...
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:
ms****@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.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/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no
rights.

Jul 9 '08 #4

This discussion thread is closed

Replies have been disabled for this discussion.