IT tutorials
 
Mobile
 

Windows Phone 8 : Windows Phone Toolkit (part 4) - ToggleSwitch Control, ExpanderView Control, PhoneTextBox Control

6/23/2013 7:54:23 PM
- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019

6. PerformanceProgressBar Control

The built-in ProgressBar control has some known performance problems, including the fact that it renders on the wrong thread (making it appear jumpy) and the fact that the animations continue even if the control is stopped. This means if you want to use a progress bar in your application, you should use the PerformanceProgressBar control6 from the Toolkit instead. This control existed because the Toolkit has much shorter release cycles and pushing a new progress bar to all phones would require an operating system update. Releasing this in the Toolkit means users can get the performance gains without waiting for the next phone update.

6 This control continues to be available in the Windows Phone Toolkit but these same changes were made to the built-in control, therefore making this control unnecessary except for backward compatibility with Windows Phone 7 and 7.1 applications.

You can simply use this control as your progress bar, instead of the built-in one, wherever you might expect to put the ProgressBar, like so:

<ProgressBar IsIndeterminate="{BindingIsBusy}" />

Replace this with the Toolkit version, like so:

<toolkit:PerformanceProgressBar IsIndeterminate="{BindingIsBusy}" />

7. ToggleSwitch Control

Although the phone includes a CheckBox control, clicking a box to enable something is not necessarily a good touch-based metaphor. In its place is a Toolkit control called a ToggleSwitch, as shown in Figure 11.

Image

FIGURE 11 ToggleSwitch example

The ToggleSwitch allows users to either tap the switch to change its value or actually slide it to the right to enable the option (or to the left to disable it). The ToggleSwitch is made up of three sections, as shown in Figure 12.

Image

FIGURE 12 ToggleSwitch components

The Header property controls what is in the section labeled #1 in Figure 12. The Content property controls what is in the section labeled #2. And the switch itself is shown in the section labeled #3. The Content of the control is usually changed as the state of the control is changed (for example, the default is On for checked and Off for unchecked). You can see the creation of a ToggleSwitch in the following XAML:

<toolkit:ToggleSwitch Header="This one is enabled"
                      Content="On"
                      IsChecked="true"/>
<toolkit:ToggleSwitch Header="This one is disabled"
                      Content="On" />

8. ExpanderView Control

The limited size of the display on the phone means that you might want to conserve the space on the screen as much as possible. One control that will help is the ExpanderView control. This control enables you to set up content that is hidden except when the user clicks the header to show the hidden content. The control consists of a header and content that can be shown when the control is tapped (see Figure 13).

Image

FIGURE 13 ExpanderView in action

To use the control, you need an instance of the ExpanderView in your XAML. There are two parts to the control: the header and the items. The header is the part of the control that is always shown, and the items contain the content that is shown after the user taps on the header. For example:

<toolkit:ExpanderView Header="Click here to Expand">
  <TextBlock>This is hidden by default</TextBlock>
</toolkit:ExpanderView>

The Header property can be text (as is shown in the previous example), or it can be a more complex control using the expanded XAML syntax:

<toolkit:ExpanderView x:Name="theExpander">
  <toolkit:ExpanderView.Header>
    <TextBlock FontWeight="Bold"
                Margin="4">Click here to expand</TextBlock>
  </toolkit:ExpanderView.Header>
</toolkit:ExpanderView>

For the content, you can just include a list of controls to show simple content or use the ItemsSource to specify a collection (much like the way a ListBox works):

public partial class MainPage : PhoneApplicationPage
{
  // Constructor
  public MainPage()
  {
    InitializeComponent();

    expander.ItemsSource = new string[]
     { "Blue", "Red", "Green", "Orange" };
  }
}

Like the ItemsSource property, you can also use data templates (like the ItemTemplate) to control what each item looks like in the ExpanderView. You should think of the ExpanderView as similar to other list controls .

9. PhoneTextBox Control

The built-in TextBox is useful but is missing some features that would make it more useful in some scenarios. It would be nice if the TextBox supported hints (for example, showing a text watermark of what belongs in a text box before it contains text), length indication, pressing the Return key to create multiple lines of text, and icons to perform actions on the text box. The PhoneTextBox fills those needs. Figure 14 shows the PhoneTextBox when it does not have focus. Notice the watermark (“Enter Tweet”) and the action icon on the right that you can hook up events to.

Image

FIGURE 14 PhoneTextBox with the Hint and ActionIcon shown

To specify these, you can simply instantiate the control and specify the Hint attribute and the ActionIcon attribute as necessary:

<toolkit:PhoneTextBox x:Name="tweetText"
  ActionIcon="Toolkit.Content/ApplicationBar.Cancel.png"
  Hint="Enter Tweet" />

The PhoneTextBox includes an event to use when the ActionIcon is tapped. This event is called ActionIconTapped:

public partial class MainPage : PhoneApplicationPage
{
  // Constructor
  public MainPage()
  {
    InitializeComponent();

    tweetText.ActionIconTapped += tweetText_ActionIconTapped;
  }

  private void tweetText_ActionIconTapped(object sender, EventArgs e)
  {
    tweetText.Text = "";
  }
}

This example shows clearing the PhoneTextBox when the user clicks the cancel icon. This is a common usability improvement over the standard TextBox.

The PhoneTextBox also supports the ability to show the user how many characters she has typed. As the user types in the control, it can show the number of characters (as well as the maximum number of characters that will be allowed), as shown in Figure 15.

Image

FIGURE 15 PhoneTextBox’s length indication support

The length indicator is supported by setting the LengthIndicatorVisible attribute to True. The LengthIndicatorThreshold attribute is also used to indicate how many characters have to be shown before the indicator is shown. This enables you to not show the indicator until the user is approaching the maximum number of characters. Finally, the DisplayedMaxLength attribute is used to indicate the maximum number in the indicator. Note that this does not limit the length of the field, but simply shows the maximum number in the indicator (which is why it’s called DisplayedMaxLength). You can see the XAML where these are specified here:

<toolkit:PhoneTextBox x:Name="tweetText"
                      DisplayedMaxLength="140"
                      LengthIndicatorVisible="True"
                      LengthIndicatorThreshold="20" />

Lastly, you can also indicate that the control should support pressing the Return key to expand the text box to include multiple lines of text. When the user uses this functionality, pressing Enter on the keyboard (or the SIP) will expand the PhoneTextBox to include the multiple lines (see Figure 16).

Image

FIGURE 16 PhoneTextBox’s AcceptReturn functionality

You specify this by using the AcceptsReturn attribute as shown here:

<toolkit:PhoneTextBox x:Name="tweetText"
                      AcceptsReturn="True" />

 
Others
 
- Windows Phone 8 : Windows Phone Toolkit (part 3) - ListPicker Control, LongListSelector Control
- Windows Phone 8 : Windows Phone Toolkit (part 2) - ContextMenu Control, DatePicker and TimePicker Controls
- Windows Phone 8 : Windows Phone Toolkit (part 1) - AutoCompleteBox Control
- Android 3 : Employing Basic Widgets - Turn the Radio Up, It's Quite a View
- Android 3 : Employing Basic Widgets - Just Another Box to Check
- iTunes on Your iPad : Purchasing or Renting Music, Videos, Podcasts, and More
- iTunes on Your iPad : iTunes U – Great Educational Content, Searching iTunes
- iTunes on Your iPad : Finding Music with Featured, Top Charts, and Genius
- BlackBerry Java Application Development - Changing the perspective
- BlackBerry Java Application Development - Starting the debugger
 
 
Top 10
 
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 2) - Wireframes,Legends
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 1) - Swimlanes
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Formatting and sizing lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Adding shapes to lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Sizing containers
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 3) - The Other Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 2) - The Data Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 1) - The Format Properties of a Control
- Microsoft Access 2010 : Form Properties and Why Should You Use Them - Working with the Properties Window
- Microsoft Visio 2013 : Using the Organization Chart Wizard with new data
Technology FAQ
- Is possible to just to use a wireless router to extend wireless access to wireless access points?
- Ruby - Insert Struct to MySql
- how to find my Symantec pcAnywhere serial number
- About direct X / Open GL issue
- How to determine eclipse version?
- What SAN cert Exchange 2010 for UM, OA?
- How do I populate a SQL Express table from Excel file?
- code for express check out with Paypal.
- Problem with Templated User Control
- ShellExecute SW_HIDE
programming4us programming4us