Skip to main content

Microsoft Silverlight

Jesse LibertyPresented by:
Jesse Liberty

Building a Skinnable Custom Control, Part 2

0 0

Leave a Comment Comments (8) RSS Feed


ramana12

Member

Member

13 Points

#1 December 06, 2008 5:28 PM

Thanks Jesse, it really helped me a lot about understand customization of controls.


JFalcon

Member

Member

30 Points

#2 December 07, 2008 12:51 PM

Jesse,

Wow, wow and WOW!

First of all, thank you for taking the time to clarify quite a few concepts.  However, I have to say this, that class "StatusControl" looks as if it's carrying the weight of the world on its shoulders.  Let's just hope they are good attributes. <smile/>

Also, during the video, I think you may have used the word 'sensual' instead of 'essential' (but I think you said that just to see who was paying attention).  <grin/>

This was, as expected, a very good video, but there is still something that's missing; not quite sure yet.  However, all those "set" properties for CLR types has been gnawing at me with all the code that needs to be written for them; I ended up writing a special function so that I could do the notify on change in one call, season to taste:

namespace JesseLiberty

{

   /// <summary>

   /// Callback made when a change is made to a value.

   /// </summary>

   public delegate void ChangeCallback();

   /// <summary>

   /// Helper used for setting properties and notifying if a change has taken place.

   /// </summary>

   public class Changer

   {

       /// <summary>

       /// Sets the and notify on change.

       /// </summary>

       /// <typeparam name="Type of me"></typeparam>

       /// <param name="oldValue">The old value to compare.</param>

       /// <param name="newValue">The new value to compare and possibly assign.</param>

       /// <param name="call">The callback if a change is actually made.</param>

       /// <returns></returns>

       public static bool SetAndNotifyOnChange<T>(ref T oldValue, ref T newValue, ChangeCallback call)

       {

           bool changed = false;

           if ((oldValue == null) && (newValue == null))

           {

               changed = false;

           }

           else if (((oldValue == null) && (newValue != null)) || !oldValue.Equals(newValue))

           {

               oldValue = newValue;

               changed = true;

               if (call != null)

               {

                   call();

               }

           }

           return changed;

       }

   }

}


JFalcon

Member

Member

30 Points

#3 December 07, 2008 12:58 PM

Leave it to me to forget to document what it returns in the code comments; however, I think it's obvious by the time you get to the end of the code. *sigh*

Thank you again for another excellent video; I'm eagerly awaiting your book, but I will wait patiently if it needs some time to stew. <grin/>

Cheers!


Steve...

Member

Member

5 Points

#4 December 12, 2008 7:51 PM

Hi Jesse,

Great videos, I can't wait for the next one.

One question, Does the logic for the custom controls have to reside in separate C# files?  Or can I keep the generic.xaml.cs file and place all the logic in there?

Many thanks.


hmaprk

Member

Member

171 Points

#5 December 19, 2008 8:30 PM

Thank you Jesse. Great Series!


a.pie...

Member

Member

119 Points

#6 January 13, 2009 6:24 PM

Very good video as always!


gigyj...

Member

Member

22 Points

#7 April 23, 2009 6:06 PM

great video

Thanks Jesse


bgnSL

Member

Member

17 Points

#8 July 01, 2009 11:52 AM

#Steve Courtney

The logic HAS to be in a separate file i.e. in a separate class

  • 1

You must be logged in to leave a comment. Click here to log in.

Microsoft Communities