Hiding the dock and menu bar

That is an attribute.

The code in the Opening event changes a property.

As the documentation mention the SystemUIVisible property, setting an attribute will not change the property as far as I know.