Does a capacitor discharge itself when the charging voltage becomes 0?
The discharge is expected (It's simple: When the charging voltage is +1, the capacitor tries to reach that value and you see the wave rising. Later, when The charging voltage changes to zero, the capacitor does the same: it tries to reach the value == 0. So you see the wave going down :-) ). The easiest way to prevent this is to add a diode in series to the capacitor.

If you wish to see a staircase without a diode, you can try increasing the duty cycle of the charging wave to (roughly) 70% and put a resistance in series to the capacitor. This will get you a rather dirty staircase during the transient phase, but it will soon settle to +1.0V