It is a good idea to add a Review My App button to your windows phone applications To do this, you can simply add the following to any button click event handler:

using Microsoft.Phone.Tasks;
MarketplaceReviewTask marketplaceReviewTask = new MarketplaceReviewTask();
marketplaceReviewTask.Show();
Advertisements

To convert a color to a brush, you can do the following:

Brush myBrushColor = new SolidColorBrush(Colors.Red);

If you have multiple TextBox controls on you screen, you might want the user to just press the enter key on the virtual keyboard to tab between them. To do this. you need to capture the KeyDown event of the control as follows:

<TextBox x:Name="TextBox1" InputScope="Text" KeyDown="TextBox1_KeyDown"/>
<TextBox x:Name="TextBox2" InputScope="Text" KeyDown="TextBox2_KeyDown"/>
<TextBox x:Name="TextBox3" InputScope="Text"/>

Now in the code behind file you can handle the navigation as follows:

private void TextBox1_KeyDown(object sender, KeyEventArgs e)
{
    if(e.Key.Equals(Key.Enter))
    {
        TextBox2.Focus();
    }
}

private void TextBox2_KeyDown(object sender, KeyEventArgs e)
{
    if(e.Key.Equals(Key.Enter))
    {
        TextBox3.Focus();
    }
}

Even though it is not common practise to have an application bar with a pivot control, you might have a valid reason to do so. If you need a different application bar for each pivot page, you can try the following:
Declare Application Bar
The first thing tou need to do is create your application bars as a resource on the page as follows:

<phone:PhoneApplicationPage.Resources>
  <shell:ApplicationBar x:Key="appBar1">
    <shell:ApplicationBarIconButton x:Name="btn1a" IconUri="/Images/image1a.png" Text="button1a" Click="btn1a_Click" />
    <shell:ApplicationBarIconButton x:Name="btn1b" IconUri="/Images/image1b.png" Text="button1b" Click="btn1b_Click" />
  </shell:ApplicationBar>
  <shell:ApplicationBar x:Key="appBar2">
    <shell:ApplicationBarIconButton x:Name="btn2a" IconUri="/Images/image2a.png" Text="button2a" Click="btn2a_Click" />
    <shell:ApplicationBarIconButton x:Name="btn2b" IconUri="/Images/image2b.png" Text="button2b" Click="btn2b_Click" />
  </shell:ApplicationBar>
</phone:PhoneApplicationPage.Resources>

Declare Pivot Page
Now you need to declare your pivot page as follows:

<controls:Pivot x:Name="myPivot" SelectionChanged="myPivot_SelectionChanged">
  <controls:PivotItem Header="pvt1">
    <Grid/>
  </controls:PivotItem>

  <controls:PivotItem Header="pvt2">
    <Grid/>
  </controls:PivotItem>
</controls:Pivot>

Code Behind
Now in the code behind, you need to show the application bar based on the pivot index as follows:

private void myPivot_SelectionChanged(object sender, SelectionChangedEventArgs e)
{            
  switch ((sender as Pivot).SelectedIndex)
  {
    case 0:
      this.ApplicationBar = this.Resources["appBar1"] as ApplicationBar;
      break;
    case 1:
      this.ApplicationBar = this.Resources["appBar2"] as ApplicationBar;
      break;
    default:
      break;
  }
}

To split a string by multiple characters into an array, you can try the following:

using System;
using System.Text.RegularExpressions;

class myClass
{
    static void Main()
    {
	string myValue = "line1\r\nline2\r\nline3";

	string[] myLines = Regex.Split(myValue , "\r\n");

	foreach (string myLine in myLines )
	{
	    Console.WriteLine(myLine);
	}
    }
}

To add border thickness to an object from code behind, you can try the following:

Border1.BorderThickness = new System.Windows.Thickness(2, 2, 2, 2);

If you want to launch a web browser from code, you can do the following:

using Microsoft.Phone.Tasks;

WebBrowserTask webbrowser = new WebBrowserTask();
webbrowser.URL = "www.zapi.co.nz";
webbrowser.Show();