title: How to make by button invisible till clicked
body: <p>I am creating a windows 8 app of which I have a scroll bar and a button. When the page is launched I want the button to be invisible until the scroll bar is touched. I make the button invisible with this line of code.</p>
  
  <pre><code>ContinueButton.Visibility = Visibility.Collapsed;
  </code></pre>
  
  <p>however when i go into the slider change part of my code and maake the visibility of the button visible it does not work. The button becomes visible even before the slider is touched. What am i doing wrong. Below is the part of code concerned.</p>
  
  <pre><code>  using System;
  using System.Collections.Generic;
  using System.IO;
  using System.Linq;
  using Ward_Obs_Roaming.Common;
  using Windows.Foundation;
  using Windows.Foundation.Collections;
  using Windows.UI;
  using Windows.UI.Xaml;
  using Windows.UI.Xaml.Controls;
  using Windows.UI.Xaml.Controls.Primitives;
  using Windows.UI.Xaml.Data;
  using Windows.UI.Xaml.Input;
  using Windows.UI.Xaml.Media;
  using Windows.UI.Xaml.Media.Imaging;
  using Windows.UI.Xaml.Navigation;
  
  // The User Control item template is documented at http://go.microsoft.com/fwlink/?LinkId=234236
  
  namespace Ward_Obs_Roaming.UI.ObsUserControls
  {
      public sealed partial class TemperatureObsControl : UserControl
      {
          public string ObsIndicatorImage
          {
              get
              {
                  if (IndicatorImage.Source != null)
                      return (IndicatorImage.Source as BitmapImage).UriSource.ToString();
                  else
                      return string.Empty;
              }
          }
  
          public string MEWSScore
          {
              get;
              set;
          }
  
          private string _Note = string.Empty;
          public string Note
          {
              get { return _Note; }
              set { _Note = value; }
          }
  
          public string TemperatureColor
          {
              get { return (TemperatureGrid.Background as SolidColorBrush).Color.ToString(); }
              set
              {
                  byte A = Byte.Parse(value.Substring(1, 2));
                  byte R = Byte.Parse(value.Substring(3, 2));
                  byte G = Byte.Parse(value.Substring(5, 2));
                  byte B = Byte.Parse(value.Substring(7, 2));
                  TemperatureGrid.Background = new SolidColorBrush(Color.FromArgb(A, R, G, B));
              }
          }
  
          public string TemperatureResult
          {
              //get { return DegreesComboBox.SelectedItem.ToString() + DecimalComboBox.SelectedItem.ToString(); }
              //set//getting data as x.y...split and set combo box items
              //{
              //    string[] splitTemperature = value.Split('.');
              //    DegreesComboBox.SelectedItem = splitTemperature[0];
              //    DecimalComboBox.SelectedItem = "." + splitTemperature[1];
              //}
  
              get
              {
                  return TemperatureSlider.Value.ToString("##.#") + "°c";
              }
              set
              {
                  value = value.Replace("°c", string.Empty);
                  TemperatureSlider.Value = Double.Parse(value.ToString());
              }
          }
  
          public Button TemperatureContinueButton
          {
              get
              {
                  return ContinueButton;
              }
          }
  
          public TemperatureObsControl()
          {
              this.InitializeComponent();
              TemperatureSlider.ValueChanged += TemperatureSlider_ValueChanged;
              TemperatureSlider.Value = 37;
              ContinueButton.Content = "No Change";
              ContinueButton.Visibility = Visibility.Collapsed;
          }
  
          void TemperatureSlider_ValueChanged(object sender, RangeBaseValueChangedEventArgs e)
          {
              ContinueButton.Content = "Update";
              ContinueButton.Visibility = Visibility.Visible;
              TemperatureTextBlock.Text = TemperatureSlider.Value.ToString("##.#") + "°c";
  
              TemperatureTextBlock.Foreground = new SolidColorBrush(Colors.White);
              MEWSScoreLabel.Foreground = new SolidColorBrush(Colors.White);
              MEWSScoreTextBlock.Foreground = new SolidColorBrush(Colors.White);
  
              //int bloodOxygenLevel = Int32.Parse(BloodOxygenSlider.Value.ToString());
              double temperature = TemperatureSlider.Value;
  
              switch (CommonVariables.ObsCategory)
              {
                  case ObsCategories.NormalObs:
                      {
                          //if (CommonVariables.is_Abnormal &amp;&amp; CommonVariables.abnormal.temperature != null)
                          //{
                          //    if (temperature &lt;= double.Parse(CommonVariables.abnormal.temperature.ElementAt&lt;string&gt;(0).Split(';').ElementAt&lt;string&gt;(1)))
                          //    {
                          //        TemperatureGrid.Background = (Application.Current as App).Resources["RedObsBrush"] as SolidColorBrush;
                          //        IndicatorImage.Source = new BitmapImage(new Uri("ms-appx:///Images/exclamationMark.png"));
                          //        MEWSScore = "3";
                          //    }
                          //    else if (temperature &lt;= double.Parse(CommonVariables.abnormal.temperature.ElementAt&lt;string&gt;(1).Split(';').ElementAt&lt;string&gt;(1)))
                          //    {
                          //        TemperatureGrid.Background = (Application.Current as App).Resources["AmberObsBrush"] as SolidColorBrush;
                          //        IndicatorImage.Source = null;
                          //        MEWSScore = "2";
                          //    }
                          //    else if (temperature &lt;= double.Parse(CommonVariables.abnormal.temperature.ElementAt&lt;string&gt;(2).Split(';').ElementAt&lt;string&gt;(1)))
                          //    {
                          //        TemperatureGrid.Background = (Application.Current as App).Resources["YellowObsBrush"] as SolidColorBrush;
                          //        IndicatorImage.Source = null;
                          //        MEWSScore = "1";
                          //        TemperatureTextBlock.Foreground = new SolidColorBrush(Colors.Black);
                          //        MEWSScoreLabel.Foreground = new SolidColorBrush(Colors.Black);
                          //        MEWSScoreTextBlock.Foreground = new SolidColorBrush(Colors.Black);
                          //    }
                          //    else if (temperature &lt;= double.Parse(CommonVariables.abnormal.temperature.ElementAt&lt;string&gt;(3).Split(';').ElementAt&lt;string&gt;(1)))
                          //    {
                          //        TemperatureGrid.Background = (Application.Current as App).Resources["GreenObsBrush"] as SolidColorBrush;
                          //        IndicatorImage.Source = new BitmapImage(new Uri("ms-appx:///Images/tickMark.png"));
                          //        MEWSScore = "0";
                          //    }
                          //    else if (temperature &lt;= double.Parse(CommonVariables.abnormal.temperature.ElementAt&lt;string&gt;(4).Split(';').ElementAt&lt;string&gt;(1)))
                          //    {
                          //        TemperatureGrid.Background = (Application.Current as App).Resources["GreenObsBrush"] as SolidColorBrush;
                          //        IndicatorImage.Source = new BitmapImage(new Uri("ms-appx:///Images/tickMark.png"));
                          //        MEWSScore = "0";
                          //    }
                          //    else if (temperature &lt;= double.Parse(CommonVariables.abnormal.temperature.ElementAt&lt;string&gt;(5).Split(';').ElementAt&lt;string&gt;(1)))
                          //    {
                          //        TemperatureGrid.Background = (Application.Current as App).Resources["YellowObsBrush"] as SolidColorBrush;
                          //        IndicatorImage.Source = null;
                          //        MEWSScore = "1";
                          //        TemperatureTextBlock.Foreground = new SolidColorBrush(Colors.Black);
                          //        MEWSScoreLabel.Foreground = new SolidColorBrush(Colors.Black);
                          //        MEWSScoreTextBlock.Foreground = new SolidColorBrush(Colors.Black);
                          //    }
                          //    else
                          //    {
                          //        TemperatureGrid.Background = (Application.Current as App).Resources["AmberObsBrush"] as SolidColorBrush;
                          //        IndicatorImage.Source = null;
                          //        MEWSScore = "2";
                          //    }
                          //}
                          if (CommonVariables.is_Abnormal &amp;&amp; CommonVariables.abnormal.temperature != null)
                          {
                              if (temperature &lt;= double.Parse(CommonVariables.abnormal.temperature.ElementAt&lt;string&gt;(0).Split(';').ElementAt&lt;string&gt;(1)))
                              {
                                  TemperatureGrid.Background = (Application.Current as App).Resources["RedObsBrush"] as SolidColorBrush;
                                  IndicatorImage.Source = new BitmapImage(new Uri("ms-appx:///Images/exclamationMark.png"));
                                  MEWSScore = "3";
                              }
                              else if (temperature &lt;= double.Parse(CommonVariables.abnormal.temperature.ElementAt&lt;string&gt;(1).Split(';').ElementAt&lt;string&gt;(1)))
                              {
                                  TemperatureGrid.Background = (Application.Current as App).Resources["AmberObsBrush"] as SolidColorBrush;
                                  IndicatorImage.Source = null;
                                  MEWSScore = "2";
                              }
                              else if (temperature &lt;= double.Parse(CommonVariables.abnormal.temperature.ElementAt&lt;string&gt;(2).Split(';').ElementAt&lt;string&gt;(1)))
                              {
                                  TemperatureGrid.Background = (Application.Current as App).Resources["YellowObsBrush"] as SolidColorBrush;
                                  IndicatorImage.Source = null;
                                  MEWSScore = "1";
                                  TemperatureTextBlock.Foreground = new SolidColorBrush(Colors.Black);
                                  MEWSScoreLabel.Foreground = new SolidColorBrush(Colors.Black);
                                  MEWSScoreTextBlock.Foreground = new SolidColorBrush(Colors.Black);
                              }
                              else if (temperature &lt;= double.Parse(CommonVariables.abnormal.temperature.ElementAt&lt;string&gt;(3).Split(';').ElementAt&lt;string&gt;(1)))
                              {
                                  TemperatureGrid.Background = (Application.Current as App).Resources["GreenObsBrush"] as SolidColorBrush;
                                  IndicatorImage.Source = new BitmapImage(new Uri("ms-appx:///Images/tickMark.png"));
                                  MEWSScore = "0";
                              }
                              else if (temperature &lt;= double.Parse(CommonVariables.abnormal.temperature.ElementAt&lt;string&gt;(4).Split(';').ElementAt&lt;string&gt;(1)))
                              {
                                  TemperatureGrid.Background = (Application.Current as App).Resources["YellowObsBrush"] as SolidColorBrush;
                                  IndicatorImage.Source = null;
                                  MEWSScore = "1";
                                  TemperatureTextBlock.Foreground = new SolidColorBrush(Colors.Black);
                                  MEWSScoreLabel.Foreground = new SolidColorBrush(Colors.Black);
                                  MEWSScoreTextBlock.Foreground = new SolidColorBrush(Colors.Black);
                              }
                              else
                              {
                                  TemperatureGrid.Background = (Application.Current as App).Resources["AmberObsBrush"] as SolidColorBrush;
                                  IndicatorImage.Source = null;
                                  MEWSScore = "2";
                              }
                          }
                          else
                          {
  
                              if (temperature &lt;= 34)//&lt;=34
                              {
                                  TemperatureGrid.Background = (Application.Current as App).Resources["RedObsBrush"] as SolidColorBrush;
                                  IndicatorImage.Source = new BitmapImage(new Uri("ms-appx:///Images/exclamationMark.png"));
                                  MEWSScore = "3";
                              }
                              else if (temperature &lt;= 35)//34-35
                              {
                                  TemperatureGrid.Background = (Application.Current as App).Resources["AmberObsBrush"] as SolidColorBrush;
                                  IndicatorImage.Source = null;
                                  MEWSScore = "2";
                              }
                              else if (temperature &lt;= 36)//35-36
                              {
                                  TemperatureGrid.Background = (Application.Current as App).Resources["YellowObsBrush"] as SolidColorBrush;
                                  IndicatorImage.Source = null;
                                  MEWSScore = "1";
                                  TemperatureTextBlock.Foreground = new SolidColorBrush(Colors.Black);
                                  MEWSScoreLabel.Foreground = new SolidColorBrush(Colors.Black);
                                  MEWSScoreTextBlock.Foreground = new SolidColorBrush(Colors.Black);
                              }
                              else if (temperature &lt;= 37)//36-37
                              {
                                  TemperatureGrid.Background = (Application.Current as App).Resources["GreenObsBrush"] as SolidColorBrush;
                                  IndicatorImage.Source = new BitmapImage(new Uri("ms-appx:///Images/tickMark.png"));
                                  MEWSScore = "0";
                              }
                              else if (temperature &lt;= 38)//37-38
                              {
                                  TemperatureGrid.Background = (Application.Current as App).Resources["GreenObsBrush"] as SolidColorBrush;
                                  IndicatorImage.Source = new BitmapImage(new Uri("ms-appx:///Images/tickMark.png"));
                                  MEWSScore = "0";
                              }
                              else if (temperature &lt;= 39)//38-39
                              {
                                  TemperatureGrid.Background = (Application.Current as App).Resources["YellowObsBrush"] as SolidColorBrush;
                                  IndicatorImage.Source = null;
                                  MEWSScore = "1";
                                  TemperatureTextBlock.Foreground = new SolidColorBrush(Colors.Black);
                                  MEWSScoreLabel.Foreground = new SolidColorBrush(Colors.Black);
                                  MEWSScoreTextBlock.Foreground = new SolidColorBrush(Colors.Black);
                              }
                              else//&gt;39
                              {
                                  TemperatureGrid.Background = (Application.Current as App).Resources["AmberObsBrush"] as SolidColorBrush;
                                  IndicatorImage.Source = null;
                                  MEWSScore = "2";
                              }
                          }
                      }
                      break;
                  case ObsCategories.NeurologicalObs:
                      {
                          if (CommonVariables.is_Abnormal &amp;&amp; CommonVariables.abnormal.temperature != null)
                          {
                              if (temperature &lt;= double.Parse(CommonVariables.abnormal.temperature.ElementAt&lt;string&gt;(0).Split(';').ElementAt&lt;string&gt;(1)))
                              {
                                  TemperatureGrid.Background = (Application.Current as App).Resources["AmberObsBrush"] as SolidColorBrush;
                                  IndicatorImage.Source = null;
                                  MEWSScore = "2";
                              }
                              else if (temperature &lt;= double.Parse(CommonVariables.abnormal.temperature.ElementAt&lt;string&gt;(1).Split(';').ElementAt&lt;string&gt;(1)))
                              {
                                  TemperatureGrid.Background = (Application.Current as App).Resources["YellowObsBrush"] as SolidColorBrush;
                                  IndicatorImage.Source = null;
                                  MEWSScore = "1";
                                  TemperatureTextBlock.Foreground = new SolidColorBrush(Colors.Black);
                                  MEWSScoreLabel.Foreground = new SolidColorBrush(Colors.Black);
                                  MEWSScoreTextBlock.Foreground = new SolidColorBrush(Colors.Black);
                              }
                              else if (temperature &lt;= double.Parse(CommonVariables.abnormal.temperature.ElementAt&lt;string&gt;(2).Split(';').ElementAt&lt;string&gt;(1)))
                              {
                                  TemperatureGrid.Background = (Application.Current as App).Resources["GreenObsBrush"] as SolidColorBrush;
                                  IndicatorImage.Source = new BitmapImage(new Uri("ms-appx:///Images/tickMark.png"));
                                  MEWSScore = "0";
                              }
                              else if (temperature &lt;= double.Parse(CommonVariables.abnormal.temperature.ElementAt&lt;string&gt;(3).Split(';').ElementAt&lt;string&gt;(1)))
                              {
                                  TemperatureGrid.Background = (Application.Current as App).Resources["YellowObsBrush"] as SolidColorBrush;
                                  IndicatorImage.Source = null;
                                  MEWSScore = "1";
                                  TemperatureTextBlock.Foreground = new SolidColorBrush(Colors.Black);
                                  MEWSScoreLabel.Foreground = new SolidColorBrush(Colors.Black);
                                  MEWSScoreTextBlock.Foreground = new SolidColorBrush(Colors.Black);
                              }
                              else
                              {
                                  TemperatureGrid.Background = (Application.Current as App).Resources["AmberObsBrush"] as SolidColorBrush;
                                  IndicatorImage.Source = null;
                                  MEWSScore = "2";
                              }
                          }
                          else
                          {
  
                              if (temperature &lt;= 35)
                              {
                                  TemperatureGrid.Background = (Application.Current as App).Resources["AmberObsBrush"] as SolidColorBrush;
                                  IndicatorImage.Source = null;
                                  MEWSScore = "2";
                              }
                              else if (temperature &lt;= 35.9 || (temperature &lt;= 38.5 &amp;&amp; temperature &gt;= 38.1))
                              {
                                  TemperatureGrid.Background = (Application.Current as App).Resources["YellowObsBrush"] as SolidColorBrush;
                                  IndicatorImage.Source = null;
                                  MEWSScore = "1";
                                  TemperatureTextBlock.Foreground = new SolidColorBrush(Colors.Black);
                                  MEWSScoreLabel.Foreground = new SolidColorBrush(Colors.Black);
                                  MEWSScoreTextBlock.Foreground = new SolidColorBrush(Colors.Black);
                              }
                              else if (temperature &lt;= 38)//36-38
                              {
                                  TemperatureGrid.Background = (Application.Current as App).Resources["GreenObsBrush"] as SolidColorBrush;
                                  IndicatorImage.Source = new BitmapImage(new Uri("ms-appx:///Images/tickMark.png"));
                                  MEWSScore = "0";
                              }
                              else//&gt;=38.6
                              {
                                  TemperatureGrid.Background = (Application.Current as App).Resources["AmberObsBrush"] as SolidColorBrush;
                                  IndicatorImage.Source = null;
                                  MEWSScore = "2";
                              }
                          }
                      }
                      break;
              }
              MEWSScoreTextBlock.Text = MEWSScore;
          }
  
          //private void DegreesComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
          //{
          //    ContinueButton.Content = "Update";
  
          //    DegreesTextBlock.Text = DegreesComboBox.SelectedItem.ToString();
          //    int selectedDegrees = Int32.Parse(DegreesComboBox.SelectedItem.ToString());
  
          //    if (selectedDegrees &lt; 30) //&lt;30
          //        BindedTemperatureSP.Background = new SolidColorBrush(Colors.LightGreen);
          //    else if (selectedDegrees &lt; 70)//30 to 70
          //        BindedTemperatureSP.Background = new SolidColorBrush(Colors.Green);
          //    else //&gt;70
          //        BindedTemperatureSP.Background = new SolidColorBrush(Colors.Red);
          //}
  
          //private void DecimalComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
          //{
          //    ContinueButton.Content = "Update";
          //    DecimalTextBlock.Text = DecimalComboBox.SelectedItem.ToString();
  
          //}
  
          private void MinusButton_Click(object sender, RoutedEventArgs e)
          {
              TemperatureSlider.Value -= TemperatureSlider.StepFrequency;
          }
  
          private void PlusButton_Click(object sender, RoutedEventArgs e)
          {
              TemperatureSlider.Value += TemperatureSlider.StepFrequency;
          }
      }
  }
  </code></pre>