title: How to format text box to currency c#.Net
body: <p>How can I format this textbox to GBP currency, like 0.00?:`</p>
  
  <pre><code>private void textBox_LostFocus(object sender, RoutedEventArgs e)
  {
      double amount = 0.0d;
      if (Double.TryParse(textBox.Text, NumberStyles.Currency, null, out amount))
      {
          textBox.Text = amount.ToString("C");
      }
  }
  </code></pre>
  
  <p>That code is rupees but I was just testing it. I couldnt reall find anything much useful. 
  The Textbox xaml:</p>
  
  <pre><code> &lt;TextBox x:Name="textBox" HorizontalAlignment="Left" Height="51" Margin="10,461,0,0" TextWrapping="Wrap" Text="{Binding TotalValue}" VerticalAlignment="Top" Width="120" KeyDown="textBox_KeyDown" TextChanged="textBox_TextChanged_1" LostFocus="textBox_LostFocus"/&gt;
  </code></pre>
  
  <p>The value right now is just something like 1.5 how can it be made to 1.50? </p>
  
  <p>The TotalValue should be set to the formated currency.</p>
  
  <pre><code>private double totalValue;
  
  public double TotalValue
  {
      get { return totalValue; }
      set
      {
          totalValue = value;
          OnPropertyChanged("TotalValue");
      }
  }
  
  protected override void OnNavigatedTo(NavigationEventArgs e)
  {
      Menu.PassedData data = e.Parameter as Menu.PassedData;
  
      if (data != null) //If data is not 0 
      {
          PassedData.Add(data); //Increment data in list view
          double tempTotalValue = 0;
          foreach (var record in PassedData)
          {
              tempTotalValue = tempTotalValue + record.Value;
          }
          TotalValue = tempTotalValue;
      }
  }
  </code></pre>