Skip to main content

Posts

The CORRECT Way to Code a Custom Exception Class

The CORRECT Way to Code a Custom Exception Class BY:  Doug Seelinger There is a lot of advice out there on how to go about building your own custom exception classes.  A lot of these sources are at least partially correct. Some are totally wrong.  Some even advocate abandoning the base System.Exception class altogether, but that’s throwing the baby out with the bathwater, in my opinion.  None that I've seen show how to serialize/deserialize your custom exception class should it have additional data in it's subclass. It’s enough to make one despair of ever finding the “right” way to build an exception class.  A lot of the confusion around exceptions comes about if you’ve ever actually tried to serialize an exception using an Xml-based serializer.  You  are  testing the code you write, correct? When attempting to serialize your nice new exception class with something like XmlSerializer, the serializer will simply choke, stating that it...

What is DispatcherTimer in wpf?

DispatcherTimer When you want to set a timer working with GUI, you always come across threading problem. The problem is that if you want to send some changes to UI that is constantly/continuously changing then that will make your UI unresponsive or in other words it will hang your UI.   To overcome from this situation, WPF gives us DispatcherTimer threading functionality that will take care of such continuously changing processing on UI thread and that will not hang your UI. We can accomplish same scenario in Win Form , through System.Windows.Forms.Timer and in WPF it is System.Windows.Threading.DispatcherTimer .   Difference between DispatcherTimer and Regular timer (System.Timers.Timer) DispatcherTimer is the regular timer. It fires its Tick event on the UI thread, you can do anything you want with the UI. System.Timers.Timer is an asynchronous timer, its Elapsed event runs on a thread pool thread. You have to be very careful in your event handler...

How to make Glossy Button usercontrol in WPF?

Searching on internet I found one interesting usercontrol which gives a look and feel like a Vista window button. You can see whole post here . However, the user control XAML code is as follows:   < UserControl x : Class ="UserControls.ucGlossyButton"              xmlns ="http://schemas.microsoft.com/winfx/2006/xaml/presentation"              xmlns : x ="http://schemas.microsoft.com/winfx/2006/xaml"              xmlns : mc ="http://schemas.openxmlformats.org/markup-compatibility/2006"               xmlns : d ="http://schemas.microsoft.com/expression/blend/2008"               mc : Ignorab...