addStyleClass("sapUiSizeCompact"); after clicking a button in UI5 : I want to change the compact density with a button. 


    onInit: function () {

            this.getView().addStyleClass("sapUiSizeCompact");
        },
works well. If I will change it in a button, it does not work.

         onOpenDialog: function (oEvent) {
            var oDialog1 = new sap.ui.commons.Dialog();
            oDialog1.setTitle("App View Settings");

            var oText = new sap.ui.commons.TextView({ text: "Compact Content Density:" });
            oDialog1.addContent(oText);

            var oToggleButton1 = new sap.ui.commons.ToggleButton({
                text: "ON, press for OFF",
                tooltip: "This is a test tooltip",
                pressed: true,
                press: function ()
                {
                    if (oToggleButton1.getPressed()) {
                        oToggleButton1.setText("ON, press for OFF");

                        this.getView().addStyleClass("sapUiSizeCompact");

                    } else {
                        oToggleButton1.setText("OFF, press for ON");

                        this.getView().removeStyleClass("sapUiSizeCompact");
                    }
                }
            });
            oDialog1.addContent(oToggleButton1);

            oDialog1.addButton(new sap.ui.commons.Button({ text: "OK", press: function () { oDialog1.close(); } }));
            oDialog1.open();
        },

How can I point to the view from inside the function?

Thanks
Marcus