Files
docs-desktop/dotnet-desktop-guide/framework/wpf/advanced/how-to-use-the-fontsizeconverter-class.md
T
Andy De George da363692ff Initial WPF content migrated (#17)
* Reset branch for WPF changes

* Convert BMP to PNG; fix link-out-of-scope err

* Add snippets for WPF... 6794 files!!!!

* Add missing snippets

* update file updated between migration

* Fix paths to include

* update breadcrumb and toc

* fix index links

* fix index links

* fix index links

* fix markdown
2020-09-04 09:46:28 -07:00

1.8 KiB

title, ms.date, helpviewer_keywords, ms.assetid
title ms.date helpviewer_keywords ms.assetid
How to: Use the FontSizeConverter Class 03/30/2017
FontSizeConverter objects [WPF]
typography [WPF], FontSizeConverter objects
3b0592bd-7223-4860-a108-a5d72f3a9178

How to: Use the FontSizeConverter Class

Example

This example shows how to create an instance of xref:System.Windows.FontSizeConverter and use it to change a font size.

The example defines a custom method called changeSize that converts the contents of a xref:System.Windows.Controls.ListBoxItem, as defined in a separate [!INCLUDETLA#tla_xaml] file, to an instance of xref:System.Double, and later into a xref:System.String. This method passes the xref:System.Windows.Controls.ListBoxItem to a xref:System.Windows.FontSizeConverter object, which converts the xref:System.Windows.Controls.ContentControl.Content%2A of a xref:System.Windows.Controls.ListBoxItem to an instance of xref:System.Double. This value is then passed back as the value of the xref:System.Windows.Controls.TextBlock.FontSize%2A property of the xref:System.Windows.Controls.TextBlock element.

This example also defines a second custom method that is called changeFamily. This method converts the xref:System.Windows.Controls.ContentControl.Content%2A of the xref:System.Windows.Controls.ListBoxItem to a xref:System.String, and then passes that value to the xref:System.Windows.Controls.TextBlock.FontFamily%2A property of the xref:System.Windows.Controls.TextBlock element.

This example does not run.

[!code-csharpFontSizeConverter#1]

See also