title: Cannot implicitly convert type class to class
body: <p>I had the same problem as this SO question : <a href="https://stackoverflow.com/questions/632713/textbox-button-and-listbox-in-a-listbox">TextBox, Button and ListBox in a ListBox</a></p>
  
  <p>So i took the answer of @Andy but it gives me trouble : </p>
  
  <pre><code>private void ButtonAddNewTask_Click(object sender, RoutedEventArgs e)
  {
      Button btn = (Button)sender;
                  IssueView curIssue = (Issue)btn.DataContext;
                  if (curIssue != null)
                  {
                      curIssue.Issue.Comments.Add(new Comment()
                      {
                          Commentary = curIssue.NewCommentName
                      });
                  }
  }
  </code></pre>
  
  <p>I wonder if it is my mistake and i didn't well adapt his answer to my code, if the post is too old or if @Andy forget something and i can't get what.</p>
  
  <p><strong>Edit</strong> My classes and adapted Button click event</p>
  
  <pre><code>public sealed class Issue
  {
      public string Name { get; set; }
      public string Detail { get; set; }
  
      private ObservableCollection&lt;Comment&gt; comments =
      new ObservableCollection&lt;Comment&gt;();
      public IList&lt;Comment&gt; Comments
      {
          get { return comments; }
      }
  }
  
  public sealed class Comment
  {
  
      // string AssociatedIssue { get; set; }
      public string Commentary { get; set; }
  }
  
  class IssueView : INotifyPropertyChanged
  {
      public Issue Issue { get; set; }
  
      private string newCommentName = string.Empty;
  
      public string NewCommentName
      {
          get { return newCommentName; }
          set
          {
              newCommentName = value;
              OnPropertyChanged("NewCommentName");
          }
      }
  
      public event PropertyChangedEventHandler PropertyChanged;
      private void OnPropertyChanged(string propName)
      {
          PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propName));
      }
  }
  </code></pre>
  
  <p>}</p>