OnRender is not as cheap as OnPaint

If you’re an old windows forms or GDI/Win32 person, you may be tempted to override OnRender for more complex UIs.    A long long time ago I wrote how to create a custom control in Windows Forms.  I showed the technique for calling Invalidate() to call OnPaint again if MouseIsOver changed. This technique turns out…

4

Avoiding throwaway layout/painting/mouse code

I’m not normally a Hungarian fanatic or anything, but it is quite easy to create “write once” layout/painting code.  If there’s ever a problem with the math the code needs to be tossed out because it’s too confusing or too difficult to update.  I think we’ve all either seen this kind of code and/or have…


How can I remember which order Margin properties are set?

Often you can stare at a margin property “10,20,30,40” in XAML and be slightly confused as to which is which property.  If I have to deal with a format over and over again I will come up with a trick to remember how to work with it. My trick is to remembering Thickness/Margin is by saying “LTRB” as in…

1

Demystifying WPF/Silverlight layout properties

What is the difference between ActualSize, RenderSize, LayoutSlot? There are quite a few properties in WPF and Silverlight for layout, and it is confusing.  It helps me to think of them in two separate categories – layout input properties (control layout), and layout output properties (set after the layout occurs) Layout input properties  ·         Width/Height…

3