Skip to main content
Hello,
Is there any way to prevent the window from closing use in the upper right CROSS?

There are some situations where I need to control the program output mode and not allow the window to be closed by this way.
Thanks
Alberto Ferraz
Hello,
Is there any way to prevent the window from closing use in the upper right CROSS?

There are some situations where I need to control the program output mode and not allow the window to be closed by this way.
Thanks
Alberto Ferraz

You can do this monitoring the Window_Closing event.

<Window x:Class="WPFApplDataGrid.Window1"

       xmlns="schemas.microsoft.com/.../presentation&quot;

       xmlns:x="schemas.microsoft.com/.../xaml&quot;

       xmlns:gl="clr-namespace:System.Globalization;assembly=mscorlib"

       Title="{Binding Titel}"

       Height="450" Width="650"

       WindowStartupLocation="CenterScreen"

       Closing="Window_Closing">

      method-id PBSchliessen_Click final private.  *> Button for Closing

      procedure division using by value sender as object e as type System.Windows.RoutedEventArgs.

          set PBSchliessenClick to true.

          invoke self::Close().

      end method.

      method-id Window_Closing.

      procedure division using by value sender as object e as type System.ComponentModel.CancelEventArgs.

           if not PBSchliessenClick

              set e::Cancel to true

           end-if.

      end method.

Werner Lanter


Hello,
Is there any way to prevent the window from closing use in the upper right CROSS?

There are some situations where I need to control the program output mode and not allow the window to be closed by this way.
Thanks
Alberto Ferraz

Hello,

Another issue resolved.

Thanks again.

Alberto Ferraz