title: Set the ToggleState of a Button on Startup And Check for the state
body: <p>I have a toggle buttons in my wpf application. On startup the togglebutton must be set. </p>
  
  <p><strong>My Xaml File:</strong> </p>
  
  <pre><code>&lt;ToggleButton Content="AUD Reset" IsChecked="True" Height="23" HorizontalAlignment="Center" Margin="0" Name="button4" Command="{Binding Path=ConnectCommand}" VerticalAlignment="Center" Width="100" /&gt;                   
  </code></pre>
  
  <p>On togglebutton click I want to check for the toggle state in my viewmodel class and if it returns true then I want to do the following operation:    </p>
  
  <p><strong>My ViewModel Class:</strong></p>
  
  <pre><code>private ICommand mUpdater;
      public ICommand ConnectCommand
      {
          get
          {
              if (mUpdater == null)
                  mUpdater = new DelegateCommand(new Action(ConnectToSelectedDevice), new Func&lt;bool&gt;(ConnectCanExecute));
  
              return mUpdater;
          }
          set
          {
              mUpdater = value;
          }
      }
  
      public bool ConnectCanExecute()
      {
          return true;
      }
  
      public void ConnectToSelectedDevice()
      {
          mComm.SetAddress(0x40);
          Byte[] buffer= new Byte[2];
          buffer[0] = 0x24;
          buffer[1] = 0x00;
  
          if(Check if button togglestate is set, if true then)
          {
           buffer[1] = 0x04;
          }
          mComm.WriteBytes(2, buffer);
      }
  </code></pre>
  
  <p>How can I check whether the togglebutton is checked or not in my viewmodel and perform the above statements.</p>
  
  <p>Please help!!            </p>