title: How to pass property value of a control to "CommandParameter" property of same control in WPF
body: <p>I am following MVVM pattern. I want to pass property value of a control to "CommandParameter" property of same control . But runtime exception of "<strong>Object reference not set to an instance of object</strong>" is being faced.</p>
  
  <p><strong>WPF:</strong></p>
  
  <pre><code> &lt;Button
              x:Name="btnBrowseFirmware1"
              Grid.Row="2"
              Grid.Column="1"
              Width="135"                    
              Height="35"
              Command="{Binding OpenFileDialogCommand}"
              CommandParameter="{Binding  Name ,ElementName=btnBrowseFirmware1}"
              Content="Browse "
              Foreground="White"
               /&gt;
  </code></pre>
  
  <p><strong>Viewmodel:</strong></p>
  
  <pre><code>  public class ConfigurationParametersViewModel : WorkspaceViewModelBase
  {
      public ICommand OpenFileDialogCommand { get; private set; }
  
      public ConfigurationParametersViewModel()
          : base("ConfigurationParameters", true)
      {
          OpenFileDialogCommand = new RelayCommand&lt;string&gt;(OpenFileDialogCommandFunc);
      }
  
      private void OpenFileDialogCommandFunc(string browseButtonName)
      {
          OpenFileDialog fileDialog = new OpenFileDialog();
          Some Code...
      }
  }
  </code></pre>