void font_Click(object sender, RoutedEventArgs e) { Button button = sender as Button; if (button == null) return; TextBlock t = button.Content as TextBlock; if (t == null) return; Action<TextBlock> func = button.Tag as Action<TextBlock>; if (func == null) return; var dlg = new FontChooser(); dlg.Owner = MainWindow.mainWindow; dlg.SetPropertiesFromObject(t); dlg.PreviewSampleText = "The quick brown fox jumps over the lazy white dog."; if (dlg.ShowDialog() == true) { dlg.ApplyPropertiesToObject(t); t.Text = GetFontName(t); func(t); } }
private void OnFontChange(object sender, RoutedEventArgs e) { FontChooser fontChooser = new FontChooser(); fontChooser.Owner = this; fontChooser.SetPropertiesFromObject(FontName); fontChooser.PreviewSampleText = FontName.Text; if (fontChooser.ShowDialog().Value) { fontChooser.ApplyPropertiesToObject(FontName); fontChooser.ApplyPropertiesToObject(SpecialFontTextBox); fontChooser.ApplyPropertiesToObject(CurrencySpecialFontSymbolLeft); fontChooser.ApplyPropertiesToObject(CurrencySpecialFontSymbol); } }