IT tutorials
 
Mobile
 

Windows Phone 8 : Controls in XAML (part 2) - RichTextBox Control, Content Controls, List Controls

2/1/2013 6:28:41 PM
- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019
RichTextBox Control

The Windows Phone SDK includes a specialized control for displaying formatted text. This control is called the RichTextBox. With the RichTextBox control you can format text by using a simplified markup including paragraph, bold, italic, and hyperlink tags.

The format is meant to provide some level of formatting like HTML text allows without requiring the complexity (or power) of the full HTML stack. For example:

<RichTextBox>
  <Paragraph>You can use inline tags to format
    <Bold>bold</Bold> text and even add
    <Italic>italics</Italic>.
  </Paragraph>
  <Paragraph>Using this Markup you can add
    <LineBreak /> line breaks and even add
    <Hyperlink NavigateUri="/SomePage.xaml">hyperlinks</Hyperlink>!
  </Paragraph>
  <Paragraph>Also arbitrary XAML:
    <InlineUIContainer>
      <StackPanel>
        <Ellipse Fill="Red"
                  Width="25"
                  Height="25" />
        <TextBox />
      </StackPanel>
    </InlineUIContainer>
  </Paragraph>
</RichTextBox>

The RichTextBox control supports a number of tags, as shown in Table 2.

Table 2. RichTextBox Markup Tags

Image

Silverlight Developers

For those of you who are using Silverlight for the desktop, the RichTextBox on the phone just supports read-only mode.

Content Controls

Content controls specifically allow you to contain arbitrary XAML inside them. The most common of these is the Button control. For example, to simply show a text message in a button you could just set the Content property, like so:

<StackPanel>
  <Button Content="Click Me" />
</StackPanel>

You can see that the content of the control (“Click Me”) is now inside the button, as shown in Figure 6.

Figure 6. Simple button with simple content

Image

But the content can take arbitrary XAML content as well:

<StackPanel>
  <Button>
    <Button.Content>
      <StackPanel>
        <Image Source="headshot.png"
                Width="100"/>
        <TextBlock>Hello</TextBlock>
      </StackPanel>
    </Button.Content>
  </Button>
</StackPanel>

This results in a button containing XAML, as shown in Figure 7.

Figure 7. Button with XAML content

Image

Notice that the content is inside the button, not replacing the XAML that makes up the button. Setting the Content property allows you to specify what is inside the button (or in most content controls, what is inside some part of the control). A content control is any control that derives from the ContentControl class. These include Button, CheckBox, RadioButton, and HyperlinkButton.

List Controls

List controls support showing any arbitrary list of items. They do this by using a property called ItemsSource. This property takes any collection that supports IEnumerable or IList. This means any type of collection (from simple arrays to complex generic collections) is supported by the list controls. The ListBox defined in XAML is pretty standard:

<StackPanel>
  <ListBox x:Name="theList" />
</StackPanel>

The real trick is when you set some collection to the ItemsSource property:

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

    theList.ItemsSource = new string[] { "One", "Two", "Three" };
  }
}

Setting the ItemsSource will show the collection and allow individual items to be selected, as shown in Figure 8.

Figure 8. List box

Image

Other list controls will follow this same interface (of setting the collection to an ItemsSource) to set the collection. By using these simple control sets, you should be able to create great experiences for your users.

 
Others
 
- Windows Phone 8 : Controls in XAML (part 1) - Using Keyboards
- Windows Phone 8 : XAML Overview - XAML Styling
- Enter Java ME on Symbian OS : Crossing to the Native Land of Symbian OS
- iphone Programming : Handling Data - Storing Data
- iphone Programming : Handling Data - Regular Expressions
- BlackBerry Java Application Development : Importing the HelloWorldDemo sample application
- BlackBerry Java Application Development : Starting the Eclipse IDE, Launching Eclipse for the first time
- Windows Phone 7 : Getting Started with XNA - Sprites in Detail (part 4) - Sprite Transparency, Alpha Tinting
- Windows Phone 7 : Getting Started with XNA - Sprites in Detail (part 3) - Partial Image Rendering, Layer Depth
- Windows Phone 7 : Getting Started with XNA - Sprites in Detail (part 2) - Rotation, Tinting
 
 
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