Overview

TextStylePicker is a Windows Phone 7 user control that allows an app user to easily customize the style of textual fields.
Based on the your app's design and usability concept, TextStylePicker can be utilized in various ways, including (but not limited to):
  • As the main content of a dedicated Font Settings page;
  • In a popup window;
  • ... Your choice here :-)

Getting Started

  • Get your Visual Studio ready with Windows Phone 7.1 SDK.
  • Get the latest archive with the library from the Downloads section.
  • Extract the KHKSoftware.TextStylePicker.dll library to some location on your disk.
  • Download Coding4Fun Toolkit, unpack it, and copy Coding4Fun.Phone.Controls.dll to the same folder where you put the KHKSoftware.TextStylePicker.dll library (if you already are using Coding4Fun in your project, this step is not necessary).
  • Download Silverlight for Windows Phone Toolkit and install it.
  • To use TextStylePicker in your project, add a reference to KHKSoftware.TextStylePicker.dll.
  • In the XAML file where you are planning to use a TextStylePicker control, add the namespace
xmlns:khkSoftware="clr-namespace:KHKSoftware.Controls;assembly=KHKSoftware.TextStylePicker" 
  • Add the control to your XAML
<khkSoftware:TextStylePicker x:Name="TextStylePickerControl"
                                           SelectedTextColor="Orange" 
                                           SelectedFontSize="40" 
                                           SelectedFontFamily="Segoe WP"
                                           MinFontSize="32" MaxFontSize="100"
                                           IsBold="True" IsItalic="False"
                                           SampleTextBackground="Black"
                                           InvertBackground="False"
                                           Applied="TextStylePickerControl_Applied"
                                           Canceled="TextStylePickerControl_Canceled"/>


Detailed API Description

Properties

All the properties have default values (see below) which will be used if no value is explicitly assigned.
  • SelectedTextColor
Set the predefined text color; it will be assigned as the initial value of the Color Picker, and of the sample text's Foreground.
DEFAULT: White.
  • SelectedFontFamily 
Set the predefined font family; it will be assigned as the initial value of the Font Family Picker, and of the sample text's FontFamily.
DEFAULT: Arial.
Only the following values are currently supported:
Arial, Arial Black, Arial Bold, Arial Italic, Calibri, Calibri Bold, Calibri Italic, Comic Sans MS, Comic Sans MS Bold, Courier New, Courier New Bold, Courier New Italic, Georgia, Georgia Bold, Georgia Italic, Lucida Sans Unicode, Malgun Gothic, Meiryo UI, Microsoft YaHei, Segoe UI, Segoe UI Bold, Segoe WP, Segoe WP Black, Segoe WP Bold, Segoe WP Light, Segoe WP Semibold, Segoe WP SemiLight, Tahoma, Tahoma Bold, Times New Roman, Times New Roman Bold, Times New Roman Italic, Trebuchet MS, Trebuchet MS Bold, Trebuchet MS Italic, Verdana, Verdana Bold, Verdana Italic, Webdings, Wingdings.
  • SelectedFontSize
Set the predefined font size; it will be assigned as the initial value of the Font Size Slider, and of the sample text's FontSize.
DEFAULT: 48.
NOTE: make sure this value is greater than the MinFontSize and smaller than the MaxFontSize.
  • MinFontSize
Set the minimal font size value; it will be assigned as the Minimum value of the Font Size Slider.
DEFAULT: 8.
  • MaxFontSize
Set the maximal font size value; it will be assigned as the Maximum value of the Font Size Slider.
DEFAULT: 72.
  • IsBold
Set the FontWeight value. If true, the Bold toggle button will be set to "On", and the sample text's FontWeight value will be set to "Bold"; otherwise, the Bold toggle button will set to "Off", and the sample text's FontWeight value will be set to "Normal".
DEFAULT: False.
  • IsItalic
Set the FontStyle value. If true, the Italic toggle button will be set to "On", and the sample text's FontStyle value will be set to "Italic"; otherwise, the Italic toggle button will set to "Off", and the sample text's FontStyle value will be set to "Normal".
DEFAULT: False.
  • SampleTextBackground
Provide the Brush that will be used as the Background of the sample text in the TextStylePickerControl.
Note that you don't necessarily have to use just colors: the property accepts any brush, so you may actually provide an image or a gradient brush.
Note: if this property is set to any non-null value, the InvertBackground property will be ignored.
There are 2 reasons for having this property:
** You may wish to see how the selected font color looks like on the actual background it is going to be used in your application.
** White (or very light-colored) text will be invisible with the Light color scheme applied, the same way as black (or very dark) text won't be visible with the Dark scheme. Suggestion: you may wish to programmatically change this parameter based on the current color scheme.
DEFAULT: null
  • InvertBackground
If set to True (and if the SampleTextBackground is not set!), the sample text's background will be changed automatically to the inverted foreground color. This is done to have the sample text always contrasted over its background, regardless of the current color scheme.
DEFAULT: False

Events

  • Canceled
Fired when the Cancel button is tapped. Use this event's handler to hide / close the TextStylePicker or its parent control.
  • Applied
Fired with TextStyleEventArgs when the Apply button is tapped.
TextStyleEventArgs has the following properties:
** FontFamily FontFamily
** double FontSize
** Color TextColor
** bool IsBold
** bool IsItalic

Last edited Mar 7, 2012 at 6:07 PM by KHK, version 14

Comments

EngDev Jan 30, 2014 at 7:36 PM 
@KHK
I added TextStylePicker as a pop up but my textbox didn't take or effect by the selected changed of TextStylePicker
MyCode is :
private void TextStylePickerControl_Applied(object sender, KHKSoftware.Controls.TextStyleEventArgs e)
{
tbx.FontFamily = TextStylePickerControl.SelectedFontFamily;
tbx.FontSize = TextStylePickerControl.SelectedFontSize;
tbx.Foreground = new SolidColorBrush(TextStylePickerControl.SelectedTextColor);
tbx.FontWeight = TextStylePickerControl.FontWeight;
this.TextStylePickerControl.Visibility = Visibility.Collapsed;


}
what's wrong of my code ?
thanks in advance