Question: I have a tab control with draggable tabs. When the mouse is released it removes the selected tab from the tabControl and adds it to its new location. My problem is that the TabControl draws itself after removing the tab, and then again when adding the tab so there is a very noticeable flicker that shows the tab behind the tab being moved.

Is there a way I can pause the UI thread so the tab control does not redraw until both the Remove and the Insert operations finish? Or perhaps some other alternative way of rearranging the tab items? The Drag/Drop operation exists in a separate code file as an Attached Property

Answer: 
I too have encountered this error and was unable to find a reason why it was happening. Like Joe Plante points out if it isn't working then something is wrong.... 

In my scenario I happened to give the Relative Layout an id (ie clicking in a blank space in the graphical layout) the same ID as my button. This was causing the wrong View to be returned by FindViewById(R.id.my\_button);

To check this in your xml see if the 

```
<RelativeLayout xmlns:tools="http://schemas.android.com/tools"
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <Button
        android:id="@+id/btnRecipe"

```
I met this in Android Studio 3.5, the IDE has not discover library by intelligence.  

I solved this by manually insert the library:

```
import android.widget.Button;

```