title: How to bind click event for each button that in a listview?
body: <p>Now I wanna develope a windows service console program via WPF. Each service is in an item of listview. <br /> link of the image of console :http://i.stack.imgur.com/eMX1d.jpg
  Therefore, I defined a class as below:</p>
  
  <pre><code>/// &lt;summary&gt;
  /// 
  /// &lt;/summary&gt;
  class ServiceItem
  {
      #region Fields
      /// &lt;summary&gt;
      /// Service Name
      /// &lt;/summary&gt;
      private string _serviceName;
      /// &lt;summary&gt;
      /// Start Button
      /// &lt;/summary&gt;
      private Button _startButton;
      /// &lt;summary&gt;
      /// Pause Button
      /// &lt;/summary&gt;
      private Button _pauseButton;
      /// &lt;summary&gt;
      /// Stop Button
      /// &lt;/summary&gt;
      private Button _stopButton;
      #endregion
  
      #region Properties
      /// &lt;summary&gt;
      /// Service Controller
      /// &lt;/summary&gt;
      private ServiceController Service
      {
          get
          {
              var services = ServiceController.GetServices();
              var service = services.AsQueryable().Where(o =&gt; o.ServiceName == _serviceName).Select(o =&gt; o).FirstOrDefault();
              return service;
          }
      }
      /// &lt;summary&gt;
      /// Service Display Name
      /// &lt;/summary&gt;
      public string ServiceDisplayName
      {
          get { return Service.DisplayName; }
      }
      /// &lt;summary&gt;
      /// Service Name
      /// &lt;/summary&gt;
      private string ServiceName
      {
          get { return Service.ServiceName; }
      }
      /// &lt;summary&gt;
      /// Service Current Status
      /// &lt;/summary&gt;
      public string Status
      {
          get
          {
              var status = Service.Status;
              switch (status)
              {
                  case ServiceControllerStatus.StartPending:
                      return "StartPending";
                  case ServiceControllerStatus.Running:
                      return "Running";//
                  case ServiceControllerStatus.PausePending:
                      return "PausePending";//
                  case ServiceControllerStatus.Paused:
                      return "Paused";//
                  case ServiceControllerStatus.StopPending:
                      return "StopPending";//
                  case ServiceControllerStatus.Stopped:
                      return "Stopped";//
                  default:
                      return "Unknow";//
              }
          }
      }
      /// &lt;summary&gt;
      /// Service Start Mode
      /// &lt;/summary&gt;
      public string StartMode
      {
          get
          {
              var startMode = ServiceHelper.GetServiceStartMode(_serviceName);
              switch (startMode)
              {
                  case ServiceStartMode.Automatic:
                      return "Automatically";//
                  case ServiceStartMode.Disabled:
                      return "Disabled";//
                  case ServiceStartMode.Manual:
                      return "Manual";//
                  default:
                      return "Unkown";//
              }
          }
      }
  
      /// &lt;summary&gt;
      /// Start Button
      /// &lt;/summary&gt;
      public Button StartButton
      {
          get
          {
              return _startButton;
          }
      }
      /// &lt;summary&gt;
      /// Pause Button
      /// &lt;/summary&gt;
      public Button PauseButton
      {
          get
          {
              return _pauseButton;
          }
      }
      /// &lt;summary&gt;
      /// Stop Button
      /// &lt;/summary&gt;
      public Button StopButton
      {
          get
          {
              return _stopButton;
          }
      }
      #endregion
  
      #region Constructor
      /// &lt;summary&gt;
      /// Init Service Instance
      /// &lt;/summary&gt;
      public ServiceItem(string serviceName)
      {
          _serviceName = serviceName;
          _startButton = new Button();
          _pauseButton = new Button();
          _stopButton = new Button();
  
          _startButton.Content = Resources.Media_Play;
          _pauseButton.Content = Resources.Media_Pause;
          _stopButton.Content = Resources.Media_Stop;
  
          _startButton.IsEnabled = Service.Status != ServiceControllerStatus.Running;
          _pauseButton.IsEnabled = Service.Status != ServiceControllerStatus.Paused;
          _stopButton.IsEnabled = Service.Status != ServiceControllerStatus.Stopped;
  
          _startButton.Click += StartButton_Click;
          _pauseButton.Click += PauseButton_Click;
          _stopButton.Click += StopButton_Click;
      }
  
      #endregion
  
      #region Methods
      /// &lt;summary&gt;
      /// Start Service
      /// &lt;/summary&gt;
      /// &lt;param name="sender"&gt;&lt;/param&gt;
      /// &lt;param name="e"&gt;&lt;/param&gt;
      public void StartButton_Click(object sender, RoutedEventArgs e)
      {
          ServiceHelper.StartService(Service);
      }
      /// &lt;summary&gt;
      /// Stop Service
      /// &lt;/summary&gt;
      /// &lt;param name="sender"&gt;&lt;/param&gt;
      /// &lt;param name="e"&gt;&lt;/param&gt;
      public void StopButton_Click(object sender, RoutedEventArgs e)
      {
          ServiceHelper.StopService(Service);
      }
      /// &lt;summary&gt;
      /// Pause Service
      /// &lt;/summary&gt;
      /// &lt;param name="sender"&gt;&lt;/param&gt;
      /// &lt;param name="e"&gt;&lt;/param&gt;
      public void PauseButton_Click(object sender, RoutedEventArgs e)
      {
          ServiceHelper.PauseService(Service);
      }
      /// &lt;summary&gt;
      /// Continue Service
      /// &lt;/summary&gt;
      /// &lt;param name="sender"&gt;&lt;/param&gt;
      /// &lt;param name="e"&gt;&lt;/param&gt;
      public void ResumeButton_Click(object sender, RoutedEventArgs e)
      {
          ServiceHelper.ResumeService(Service);
      }
      #endregion
  }
  </code></pre>
  
  <p>and the corresponding listview xaml is as below:<br /></p>
  
  <pre><code> &lt;ListView x:Name="ServiceList" Background="#353535" BorderBrush="#353535" Foreground="White" Height="295" ItemsSource="{Binding}"&gt;
              &lt;ListView.View&gt;
                  &lt;GridView AllowsColumnReorder="True"&gt;
                      &lt;GridView.Columns&gt;
                          &lt;GridViewColumn Width="auto" Header="Name" DisplayMemberBinding="{Binding ServiceDisplayName}"&gt;&lt;/GridViewColumn&gt;
                          &lt;GridViewColumn Width="auto" Header="Status" DisplayMemberBinding="{Binding Status}"&gt;&lt;/GridViewColumn&gt;
                          &lt;GridViewColumn Width="auto" Header="StartMode" DisplayMemberBinding="{Binding StartMode}"&gt;&lt;/GridViewColumn&gt;
                          &lt;GridViewColumn Width="auto" Header="Operation"&gt;
                              &lt;GridViewColumn.CellTemplate&gt;
                                  &lt;DataTemplate&gt;
                                      &lt;Grid x:Name="grdOperations" x:Uid="grdOperations"&gt;
                                          &lt;Grid.ColumnDefinitions&gt;
                                              &lt;ColumnDefinition Width="*"&gt;&lt;/ColumnDefinition&gt;
                                              &lt;ColumnDefinition Width="*"&gt;&lt;/ColumnDefinition&gt;
                                              &lt;ColumnDefinition Width="*"&gt;&lt;/ColumnDefinition&gt;
                                          &lt;/Grid.ColumnDefinitions&gt;
                                          &lt;Button Grid.Column="0" Height="24" Width="24" Style="{StaticResource ImageButton}" &gt;
                                              &lt;Image Source="Resources/Media Play.png"&gt;&lt;/Image&gt;
                                          &lt;/Button&gt;
                                          &lt;Button Grid.Column="1" Height="24" Width="24" Margin="1,0,1,0" Style="{StaticResource ImageButton}"&gt;
                                              &lt;Image Source="Resources/Media Pause.png"&gt;&lt;/Image&gt;
                                          &lt;/Button&gt;
                                          &lt;Button Grid.Column="2" Height="24" Width="24" Style="{StaticResource ImageButton}"&gt;
                                              &lt;Image Source="Resources/Media Stop.png"&gt;&lt;/Image&gt;
                                          &lt;/Button&gt;
                                      &lt;/Grid&gt;
                                  &lt;/DataTemplate&gt;
                              &lt;/GridViewColumn.CellTemplate&gt;
                          &lt;/GridViewColumn&gt;
  
                      &lt;/GridView.Columns&gt;
                  &lt;/GridView&gt;
              &lt;/ListView.View&gt;
          &lt;/ListView&gt;
  </code></pre>
  
  <p><br />
  I created the ServiceItem instance collection and bind it to the ListView:<br /></p>
  
  <pre><code>var services = new List&lt;ServiceItem&gt;()
          {
              new ServiceItem("AxInstSV"),
              new ServiceItem("PeerDistSvc")
          };
          ServiceList.ItemsSource = services;
  </code></pre>
  
  <p>now the problem is how counld/should I bind the start/pause/stop event method to each button?</p>