xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="FontSizeConverter_Csharp.Window1"
Title="FontSizeConverter Sample">
this is a test
5
8
11
14
17
20
23
26
29
32
Arial
Courier New
Tahoma
Times New Roman
Verdana
//File:Window.xaml.cs
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Navigation;
using System.Windows.Media;
namespace FontSizeConverter_Csharp
{
public partial class Window1 : Window
{
public void changeSize(object sender, SelectionChangedEventArgs args)
{
ListBoxItem li = ((sender as ListBox).SelectedItem as ListBoxItem);
FontSizeConverter myFontSizeConverter = new FontSizeConverter();
text1.FontSize = (Double)myFontSizeConverter.ConvertFromString(li.Content.ToString());
}
public void changeFamily(object sender, SelectionChangedEventArgs args)
{
ListBoxItem li2 = ((sender as ListBox).SelectedItem as ListBoxItem);
text1.FontFamily = new System.Windows.Media.FontFamily(li2.Content.ToString());
}
}
}