title: Change the Border.BorderBrush value with C# Windows Phone 7.1
body: <p>I want to change the color of borders in a windows phone app depending on the currently selected theme. I have wrote the following but its not working. It is always white color border irrespective of the theme selected.</p>
  
  <p>Here is the xaml code used for the app(contacts.xaml).</p>
  
  <p>[XAML CODE]</p>
  
  <pre><code>       &lt;StackPanel x:Name="StackPost_Viewer"&gt;
              &lt;Border BorderBrush="White" BorderThickness="3" HorizontalAlignment="Left" Height="100" Margin="10,10,0,0" VerticalAlignment="Top" Width="436" Tap="Show_ContactList_gsecs"&gt;
                  &lt;TextBlock TextWrapping="Wrap" Text="General Secretaries Social and Cultural" FontSize="36" HorizontalAlignment="Center" VerticalAlignment="Center"/&gt;
              &lt;/Border&gt;
              &lt;Border BorderBrush="White" BorderThickness="3" HorizontalAlignment="Left" Height="100" Margin="10,10,0,0" VerticalAlignment="Top" Width="436" Tap="Show_ContactList_publicity"&gt;
                  &lt;TextBlock TextWrapping="Wrap" Text="Publicity" FontSize="36" HorizontalAlignment="Center" VerticalAlignment="Center"/&gt;
              &lt;/Border&gt;
              &lt;Border BorderBrush="White" BorderThickness="3" HorizontalAlignment="Left" Height="100" Margin="10,10,0,0" VerticalAlignment="Top" Width="436" Tap="Show_ContactList_events"&gt;
                  &lt;TextBlock TextWrapping="Wrap" Text="Events" FontSize="36" HorizontalAlignment="Center" VerticalAlignment="Center"/&gt;
              &lt;/Border&gt;
              &lt;Border BorderBrush="White" BorderThickness="3" HorizontalAlignment="Left" Height="100" Margin="10,10,0,0" VerticalAlignment="Top" Width="436" Tap="Show_ContactList_spons"&gt;
                  &lt;TextBlock TextWrapping="Wrap" Text="Marketing and Sponsorship" FontSize="36" HorizontalAlignment="Center" VerticalAlignment="Center"/&gt;
              &lt;/Border&gt;
              &lt;Border BorderBrush="White" BorderThickness="3" HorizontalAlignment="Left" Height="100" Margin="10,10,0,0" VerticalAlignment="Top" Width="436" Tap="Show_ContactList_finance"&gt;
                  &lt;TextBlock TextWrapping="Wrap" Text="Finance" FontSize="36" HorizontalAlignment="Center" VerticalAlignment="Center"/&gt;
              &lt;/Border&gt;
          &lt;/StackPanel&gt;
  </code></pre>
  
  <p>Corresponding c# code(contacts.xaml.cs)</p>
  
  <p>[C# CODE]</p>
  
  <pre><code>    public contacts()
      {
          InitializeComponent();
          if (!isDarkTheme())
          {
              StackPanel main_stack = StackContact_Viewer;
              var borders = main_stack.Children.OfType&lt;Border&gt;();
              foreach (Border each in borders)
              {
                  each.BorderBrush = new SolidColorBrush(Colors.Black);
              }
          }
          else
          {
              StackPanel main_stack = StackContact_Viewer;
              var borders = main_stack.Children.OfType&lt;Border&gt;();
              foreach (var each in borders)
              {
                  each.BorderBrush = new SolidColorBrush(Colors.White);
              }
  
          }
  
      }
      private bool isDarkTheme()
      {
          return Visibility.Visible == (Visibility)Application.Current.Resources["PhoneDarkThemeVisibility"];
      }
  </code></pre>