![]() The C# code behind the XAML is trivial, as it handles the OK button setting the Font property that exposes the font selected by the user. Notice how the Window makes use of the User Controls defined above, as objects belonging to the "local:" namespace. I added this feature by modifying the CollectionViewSource resource as follows: ![]() The original control did not sort the list of fonts. Private void superCombo_Loaded( object sender, RoutedEventArgs e)Īs I said before, the Font Chooser User Control is a little modification of. Private void superCombo_DropDownClosed( object sender, EventArgs e) RoutedEventArgs newEventArgs = new RoutedEventArgs(ColorPicker.ColorChangedEvent) Public SolidColorBrush BrushColor įontColor fc = (FontColor) this.GetValue(SelectedColorProperty) įc = AvailableColors.GetFontColor( " Black") NET project and be used as a standard dialog form: So that it can be easily referenced in a. The DLL library that contains Font Picker is called ColorFont and it is composed by two XAML User Controls: It is easy to understand why: the typical scenario is that the user selects font, then she is not satisfied and clicks again to display the dialog: she does not want a "default" font again, she wants to modify the font she selected in the first attempt. Also, the Font Picker had to let the user choose the font foreground color.Īn important requisite, that was missing from the works quoted in the credits, was that the dialog form should be able to be initialized with a "current" font. The Font Picker had to allow the user to choose a font with every option: family, style, size, weight and stretch. ![]() I decided to build a "WPF User Control" in the form of two different reusable controls (the Color Picker and the Font Picker) and a Window Dialog in the fashion of Windows Forms Task Dialogs. I needed in first place a pluggable WPF library, so that I can easily add it to any of my projects. Without these two noticeable pieces of software, my WPF Font Picker would have never seen the light. The second one is the Color Combobox Picker by Muhammed Sudheer. My WPF Font Picker is based on the remix of two different works: a Font Chooser in XAML and a Color Combobox control. The first one is the Pure XAML Font Chooser by Cheng Norris. Well, not entirely on my own: as any smart programmer knows, nothing is built from scratch anymore. Since I needed one, I decided to write one on my own. Surprisingly, the Windows Presentation Framework (WPF) comes with no predefined dialog forms, so for instance there is no Font Dialog or Color Dialog in the default toolbox.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |