* net-current-v30plus-md.md * net-current-v40plus-md.md * tla2sharptla-ui-md.md * tla2sharptla-uiautomation-md.md * tla2sharptla-winclient-md.md * tla2sharptla-xaml-md.md * tlasharptla-ui-md.md * tlasharptla-uiautomation-md.md * tlasharptla-winclient-md.md * tlasharptla-xaml-md.md * fix warnings
1.7 KiB
title, ms.date, helpviewer_keywords, ms.assetid
| title | ms.date | helpviewer_keywords | ms.assetid | ||
|---|---|---|---|---|---|
| How to: Use the FontSizeConverter Class | 03/30/2017 |
|
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 Extensible Application Markup Language (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]