title: Removing Item from observable collection causes textbox to focus
body: <p>I have a textbox that is on the same screen as a listbox. When I remove an item from the listbox, which is bound to an observable collection, the textbox gains focus. Is there a way to stop this from happening?</p>
  
  <p>I am using MVVM but am open to putting some code in the code behind if it fixes this problem.</p>
  
  <p>EDIT:</p>
  
  <p>CodeBehind View:</p>
  
  <p>namespace Offload.WinPhone.Views
  {
      using System.Windows.Controls;
      using Microsoft.Phone.Controls;</p>
  
  <pre><code>public partial class MainPageView : PhoneApplicationPage
  {
      public MainPageView()
      {
          InitializeComponent();
      }
  
      private void QuickNoteBodyEditor_TextChanged(object sender, TextChangedEventArgs e)
      {
          var senderAsTextbox = (TextBox)sender;
  
          if (senderAsTextbox.Text.Length == 0)
              this.Focus();
      }
  }
  </code></pre>
  
  <p>}</p>
  
  <p>View:</p>
  
  <p></p>
  
  <pre><code>&lt;Grid x:Name="LayoutRoot" Background="Transparent" Margin="12,0,12,0"&gt;
  
      &lt;Grid.RowDefinitions&gt;
          &lt;RowDefinition Height="Auto"/&gt;
          &lt;RowDefinition Height="*"/&gt;
          &lt;RowDefinition Height="Auto"/&gt;
      &lt;/Grid.RowDefinitions&gt;
  
      &lt;TextBlock Text="OFFLOAD" FontFamily="Segoe WP Bold" Grid.Row="0"/&gt;
  
      &lt;ListBox x:Name="QuickNotes" Grid.Row="1" TabIndex="1"&gt;
          &lt;ListBox.ItemTemplate&gt;
              &lt;DataTemplate&gt;
                  &lt;StackPanel Margin="0,5,0,5" Orientation="Vertical"&gt;
                      &lt;TextBlock Style="{StaticResource PhoneTextExtraLargeStyle}" TextWrapping="Wrap" Text="{Binding Body}"/&gt;
                      &lt;TextBlock Style="{StaticResource PhoneTextAccentStyle}" Text="{Binding Timestamp, StringFormat='{}{0:dd MMM HH:mm}'}"/&gt;
                  &lt;/StackPanel&gt;
              &lt;/DataTemplate&gt;
          &lt;/ListBox.ItemTemplate&gt;  
      &lt;/ListBox&gt;
  
      &lt;TextBox x:Name="QuickNoteBodyEditor" AcceptsReturn="True" Grid.Row="2" InputScope="Chat" TextChanged="QuickNoteBodyEditor_TextChanged" IsTabStop="True" /&gt;
  
  &lt;/Grid&gt;
  
  &lt;phone:PhoneApplicationPage.ApplicationBar&gt;
      &lt;shell:ApplicationBar IsVisible="True" IsMenuEnabled="True"&gt;
  
          &lt;shell:ApplicationBar.Buttons&gt;
              &lt;cal:AppBarButton IconUri="/AppFramework/Resources/Icons/Add.png" Text="Add" Message="AddQuickNote" /&gt;
              &lt;cal:AppBarButton IconUri="/AppFramework/Resources/Icons/Delete.png" Text="Delete" Message="DeleteSelectedQuickNote" /&gt;
          &lt;/shell:ApplicationBar.Buttons&gt;
  
          &lt;shell:ApplicationBar.MenuItems&gt;
              &lt;cal:AppBarMenuItem Text="About" Message="NavigateToAddAccountView"/&gt;
              &lt;cal:AppBarMenuItem Text="Review" Message="NavigateToAddAccountView"/&gt;
          &lt;/shell:ApplicationBar.MenuItems&gt;
  
      &lt;/shell:ApplicationBar&gt;
  &lt;/phone:PhoneApplicationPage.ApplicationBar&gt;
  </code></pre>
  
  <p></p>
  
  <p>ViewModel:</p>
  
  <pre><code>public class MainPageViewModel : PropertyChangedBase
  {
      private ObservableCollection&lt;QuickNote&gt; quickNotes;
      private string quickNoteBodyEditor;
      private QuickNote selectedQuickNote;
  
      // Databound Properties
  
      public string QuickNoteBodyEditor 
      {
          get { return quickNoteBodyEditor; }
          set { quickNoteBodyEditor = value; NotifyOfPropertyChange(() =&gt; QuickNoteBodyEditor); NotifyOfPropertyChange(() =&gt; CanAddQuickNote);}
      }
  
      public QuickNote SelectedQuickNote
      {
          get { return selectedQuickNote; }
          set { selectedQuickNote = value; NotifyOfPropertyChange(() =&gt; SelectedQuickNote); NotifyOfPropertyChange(() =&gt; CanDeleteSelectedQuickNote); }
      }
  
      public ObservableCollection&lt;QuickNote&gt; QuickNotes
      {
          get { return quickNotes; }
          set { quickNotes = value; NotifyOfPropertyChange(() =&gt; QuickNotes); }
      }
  
      // Guard Clauses
  
      public bool CanAddQuickNote 
      {
          get { return !string.IsNullOrWhiteSpace(quickNoteBodyEditor); } 
      }
  
      public bool CanDeleteSelectedQuickNote
      {
          get{ return selectedQuickNote == null ? false : true; }
      }
  
      // Constructors
  
      public MainPageViewModel()
      {
          GetQuickNotesFromIsolatedStorage();
          WatchWhatsGotFocus.StartWatching();
      }
  
      // Public Methods
  
      public void AddQuickNote()
      {
          if (CanAddQuickNote)
          {
              quickNotes.Add(new QuickNote(quickNoteBodyEditor, DateTime.Now));
              AddQuickNotesToIsolatedStorage();
  
              quickNoteBodyEditor = string.Empty;
  
              NotifyOfPropertyChange(() =&gt; QuickNoteBodyEditor);
              NotifyOfPropertyChange(() =&gt; QuickNotes);
          }
      }
  
      public void DeleteSelectedQuickNote()
      {
          if (CanDeleteSelectedQuickNote)
          {
              quickNotes.Remove(selectedQuickNote);
              AddQuickNotesToIsolatedStorage();
  
              selectedQuickNote = null;
  
              NotifyOfPropertyChange(() =&gt; SelectedQuickNote);
              NotifyOfPropertyChange(() =&gt; QuickNotes);
          }
      }
  
      private void GetQuickNotesFromIsolatedStorage()
      {
          quickNotes = IsolatedStorage.Get&lt;ObservableCollection&lt;QuickNote&gt;&gt;("QuickNoteList");
      }
  
      private void AddQuickNotesToIsolatedStorage()
      {
          IsolatedStorage.Add("QuickNoteList", quickNotes);
      }
  }
  </code></pre>