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: 
Is the exception a ClassCastException? If so then the view you are finding with the id `my_button` isn't a button. If it's a NullPointerException then there is no view with the id my\_button. This could be cause by not calling setContent() before you try to find the views.
In my case, I missed that I'm using an ImageButton.

Check it too