exception_handler_wpf
no way to compare when less than two revisions
Differences
This shows you the differences between two versions of the page.
— | exception_handler_wpf [2018/03/25 18:02] (current) – created wolfgangriedmann | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Exception handler for a WPF application ====== | ||
+ | |||
+ | The following piece of code can be used to display an exception text in a WPF GUI application. Please don't forget to log the exception also to a logfile. You can take this code also as sample how to build a WPF window from pure code. | ||
+ | |||
+ | < | ||
+ | constructor( oEx as Exception ) | ||
+ | |||
+ | self: | ||
+ | |||
+ | return | ||
+ | |||
+ | method Initialize( oEx as Exception ) as void | ||
+ | local oGrid as Grid | ||
+ | local oTextBlock as TextBlock | ||
+ | local oButton as Button | ||
+ | local oMargin as Thickness | ||
+ | |||
+ | oMargin := Thickness{ 10 } | ||
+ | // Grid | ||
+ | oGrid := Grid{} | ||
+ | oGrid: | ||
+ | oGrid: | ||
+ | oGrid: | ||
+ | oGrid: | ||
+ | // display the error | ||
+ | oTextBlock := TextBlock{} | ||
+ | oTextBlock: | ||
+ | oTextBlock: | ||
+ | Grid.SetColumn( oTextBlock, 0 ) | ||
+ | Grid.SetRow( oTextBlock, 0 ) | ||
+ | oGrid: | ||
+ | // display the callstack | ||
+ | oTextBlock := TextBlock{} | ||
+ | oTextBlock: | ||
+ | oTextBlock: | ||
+ | Grid.SetColumn( oTextBlock, 0 ) | ||
+ | Grid.SetRow( oTextBlock, 1 ) | ||
+ | oGrid: | ||
+ | // Close button | ||
+ | oButton := Button{} | ||
+ | oButton: | ||
+ | oButton: | ||
+ | oButton: | ||
+ | Grid.SetColumn( oButton, 0 ) | ||
+ | Grid.SetRow( oButton, 2 ) | ||
+ | oGrid: | ||
+ | |||
+ | self: | ||
+ | |||
+ | return | ||
+ | |||
+ | method OkButtonClick( oSender as object, e as RoutedEventArgs ) as void | ||
+ | |||
+ | self: | ||
+ | |||
+ | return | ||
+ | |||
+ | end class</ | ||
exception_handler_wpf.txt · Last modified: 2018/03/25 18:02 by wolfgangriedmann