ChooseFont dlg = new ChooseFont(sampleText);
if (dlg.ShowDialog() == true)
{
dlg.ApplyTo(sampleText);
}
它的问题在于,对于中文字体的字体名显示的是英文.
优点在于可以设置颜色,而且启动速度较快
第二个下载地址:http://blogs.msdn.com/b/text/archive/2006/11/01/sample-font-chooser.aspx
使用方法类似,把项目的输出改成类库,删除App.xaml和MainWindow.xaml,生成FontDialogSample.dll.
使用的时候加入引用FontDialogSample.dll,童谣需要加入using FontDialogSample;
以下为使用实例
FontChooser fontChooser = new FontChooser();
fontChooser.Owner = this;
fontChooser.SetPropertiesFromObject(textBox);
fontChooser.PreviewSampleText = textBox.SelectedText;
if (fontChooser.ShowDialog().Value)
{
fontChooser.ApplyPropertiesToObject(textBox);
}
它的优点就是全面
缺点是第一次调用的时候非常慢,之后再调用会好一些.而且对话框也太大了.