Complete sample application that shows my problem