Silverlight 2 Dynamic Bordered Image

•February 17, 2009 • Leave a Comment

what’s up people, I had to drop this little help for those people trying to display a border around an image just like a postcard. Sounds easy, right? good luck, I got it to work finally after messing w/ a bunch of events including SizeChanged, Loaded and finally LayoutUpdated. These events are exposed in the Image control. What I was doing is loading an image from WebService, and displaying it in an Auto Sized Border, no hardcoding sizes here, I had to place the border around the image using the Rendered ActualWidth and ActualHeight of the Image control to make it snug( after Image was downloaded and rendered), if not you get the border which expands the entire availble area, instead of nice and snug around the image. So, all I had to do was wire up an delegate for the Image.LayoutUpdated and as the Image control changed size, I was able to update the Border to use same size as Image ! I’m not sure if it will work for everyone, but it did for me ;)

ADO.Net data services client : Inserting record Many to Many

•February 3, 2009 • 1 Comment

ok, so I’ve been learning what’s good and bad about this new technology…just a quick note, if your trying to insert a new record into a Many to Many relationship, you must use AddLink. SetLink is for 1 to Many relationships…that bit me in the ass for a good few hours…hope it helps somebody else.

Silverlight 2 Dynamic ItemsTemplate

•November 13, 2008 • Leave a Comment

I just got a workaround from Scott Guthrie and other Silverlight team members ( David Anson ) to resolve why changing a ListBox’s ItemsTemplate would not update the layout. What a quick response btw, less than 2-3hrs it was there in my inbox, I was so happy !!! Here is a code snippet…

try
{
    // show the correct layout...
    if (this.sldCrateLayout != null)
    {
        int layoutNum = (int)this.sldCrateLayout.Value;

        switch (layoutNum)
        {
            case 1:
                // Circular
                this.lbDigiCrates.ItemsPanel = Resources["circularPanelTemplate"] as ItemsPanelTemplate;
                break;
            case 2:
                // Wrap
                this.lbDigiCrates.ItemsPanel = Resources["wrapPanelTemplate"] as ItemsPanelTemplate;
                break;
            case 3:
                // Uniform
                this.lbDigiCrates.ItemsPanel = Resources["uniformGridPanelTemplate"] as ItemsPanelTemplate;
                break;
            case 4:
                // Carousel
                this.lbDigiCrates.ItemsPanel = Resources["carouselPanelTemplate"] as ItemsPanelTemplate;
                break;
            case 5:
                // Grid
                this.lbDigiCrates.ItemsPanel = null;
                break;
            case 6:
                // List
                break;
        }

        // Rebounce the ItemsPanel template so it can repopulate
        // Trick provided by David Anson from MS and Scott Guthrie!!!
        var t = lbDigiCrates.Template;
        lbDigiCrates.Template = null;
        lbDigiCrates.Template = t;
    }
}
catch (Exception ex) 

Silverlight2 UniformGrid Panel

•November 10, 2008 • 1 Comment

Another layout control missing in Silverlight2 is the UniformGrid…so I decided to build my own again… (which by the way MS has released their set of Silverlight Controls under Silverlight Toolkit which contains a WrapPanel along w/ many other goodiess but I didn’t see the UniformGrid, unless I’m going blind…;)…well all I know is Wow!!, that was a pain in the donkey for surez;)…anyways, after getting the algorithm kinda down it worked like a charm…I still need to fix my math to fill the container completely but right now this is good enough for me.  Below is a shot from…you guessed it; skratchn.com using the UniformGridPanel I just implemented to display the album covers and crates. The UniformGrid actually took me a bit longer than expected but nonetheless it was worth the effort.

Silverlight2 WrapPanel

•November 10, 2008 • 1 Comment

Just whipped up a little WrapPanel control since it is missing from Silverlight2 and was so damn easy to build, why did MS not ship one I’m not sure….but for me it took less than 10 minutes, maybe even 5 minutes…perhaps that is why, they only do the tricky ones ;)   This control keeps the desired size of the Child element and wraps only left to right top to bottom for now…should start scrolling vertically.  I’m going to build the UniformGrid now, since that seems pretty easy as well and is a really cool layout control.  Here’s what it looks like w/ the DigiCR8 System.

Silverlight2 WrapPanel

Silverlight2 WrapPanel

Skratchn.com in the workz…Silverlight2 app

•November 10, 2008 • 1 Comment

Yo, i’ve been busy trying to pick up some skills w/ Silverlight2 and all that new .Net Framework 3.5 stuff.  I’ve really enjoyed building this little project and it’s been full of unexpected challenging things; mostly related to Silverlight’s limitations..I’ll write a blog about that later… Many things were a pain in the ass, but overall it’s been cake once you get the hang of programming Xaml by hand and trying to use Blend along w/ VS2008.  I’d like to share w/ everyone some of my technologies and ideas of where i’m thinking of taking skratchn.com and the whole digicr8 concept.  Stay tuned as I stare into pixel space and figure out what to do next…check out a thumbnail below and a link to the app!!  skratchn.com 2009 CTP

skratchn.com menu w/ animation

skratchn.com menu w/ animation

skratchn.com DigiCR8 System preview 2009

skratchn.com preview 2009

 
Follow

Get every new post delivered to your Inbox.