Thursday, April 03, 2008

Debug breakpoints stopped working in my Silverlight 2.0 project.

There's one very good reason why debugging won't work which Karsten blogs about in his post "What To Do When Breakpoints Disappear and Debugging Dies In Silverlight 2".

But that wasn't my problem. I had SL debugging on.

My project was from the template which creates a Web App to host and I finally realized that somehow the web app and the silverlight app were no longer linked. WHen I recreated the link debugging was back. Not that I need to debug becuase like you, my code is perfect the first time around! ;-)

Thursday, April 03, 2008 7:52:40 PM (Eastern Standard Time, UTC-05:00)  #     |  Comments [0]  | 
 Saturday, March 15, 2008

THANK YOU!!!

Saturday, March 15, 2008 9:03:12 AM (Eastern Standard Time, UTC-05:00)  #     |  Comments [1]  | 
 Friday, March 14, 2008

Okay, my poor little ego is saved... I thought I was doing something horribly wrong with the new Silverlight tools, but it wasn't me after all. Read more....

[A New DevLife Post]

Friday, March 14, 2008 7:38:44 PM (Eastern Standard Time, UTC-05:00)  #     |  Comments [0]  | 
 Wednesday, March 05, 2008

Last week, I pointed out a screenshot in Expression Blend from Scott Guthrie's post about Silverligth 2.0, showing a lot of new controls. Roger Jennings asked - so where's this datagrid I keep hearing about? I thought perhaps it was in the additional tools that were not visible in the screenshot, since there was a scrollbar.

I installed Silverlight 2.0 and the March Preview of Expression Blend 2.5 (oh dear, another ".5" version) and opened up to see what else was there. Here's the default view.

Here are all of the controls in the asset library.

No DataGrid.

BUt then I created a new Silverlight app in VS2008. I can't get over the Blend designer actually being right there inside of the VS IDE! And there is the DataGrid. But alas, no InkPresenter.

I spent some time (even digging around the dlls in Reflector) trying to find the SL version of the InkPresenter but finally decided to just give in.

Wednesday, March 05, 2008 7:58:12 PM (Eastern Standard Time, UTC-05:00)  #     |  Comments [0]  | 

[update: hmmm, I gave up trying to get the app working and started a new one from scratch, so "good to go" was only relative!]

The MSBuild files for Silverlight 1.1 were tucked inside of the MSBuild's Visual Studio folder. Now they are in their own folder.

If you try to open up a project created with Silverlight 1.1 in VS2008, you will get a message that the C:\program files\msbuild\microsoft\visualSutiod\v9.0\Silverlight\Microsoft.Silverlight.Csharp.targets (or VisualBasic.targets) file can't be found and you won't be allowed to open the project.

Click OK to let the solution load.

In the Solution Explorer you should seethe project listed but unavailable. Right click on it and choose the Edit option. The project's MSBuild file will open.

Scroll down until you find the Import Project= element that points to the targets file.

All you should have to do is replace

"VisualStudio9.0\Silverlight\"

with

"Silverlight\v2.0\"

Then you can reload the project after saving.

[continuing...]

Next steps are to get the right APIs referenced. Add references should show you relevant Silvelright 2.0 APIs. You'll see that the old ones are no longer valid (the warning icon). YOu can delete them. In there place you need to ref:

  • System [in C:\Program Files\Microsoft Silverlight\2.0.30226.2]
  • System.Core [in C:\Program Files\Microsoft Silverlight\2.0.30226.2]
  • System.Windows [in C:\Program Files\Microsoft Silverlight\2.0.30226.2]
  • System.Windows.Browser [in C:\Program Files\Microsoft Silverlight\2.0.30226.2]
  • System.WIndows.Controls [in C:\Program Files\Microsoft SDKs\Silverlight\v2.0\Libraries\Client]System.Windows.Controls.Extended [in C:\Program Files\Microsoft SDKs\Silverlight\v2.0\Libraries\Client]
  • System.XML [in C:\Program Files\Microsoft Silverlight\2.0.30226.2]

I'm down to one error and when I figure it out I'll append again.

Wednesday, March 05, 2008 5:34:01 PM (Eastern Standard Time, UTC-05:00)  #     |  Comments [0]  | 

At the last minute, I had to forego heading out to Las Vegas for MIX but thanks to streaming, I was able to watch the 3 hour keynote given/hosted by Ray Ozzie and Scott Guthrie. I say "hosted" becasue there were many many amazing demos of work different companies have been doing.

There will be so many people blogging about the keynote that I don't want to reiterate everything. A few highlights were seeing some major innovation in IE8 (along with Dean's cool t-shirt - the ie logo and the e in "eight" result in a clever image) and  Silverlight 2 goodness - especially Vertigo's silverlight app for Hard Rock Cafe (go Scott (even if he doesn't post a lot on his blog!)). Thanks to Guy Burstein who posted all of the critical links in a few blog posts this morning, there's also one to the technology that Vertigo used called Deep Zoom.

Okay, Scott Guthrie juggling for a Cirque du Soleil audition was pretty cute, too.

The real goods are:

  • IE8 Beta
  • Silverlight 2 Beta and dev tools and SDK
  • Expression Studio Beta (don't forget Expression Blend 2.5 March 2008 Preview)
  • A passing mention that the next preview of MVC is available.

Because he did such a good job at it, I'm going to take advantage of Guy's posts with lots and lots of links.

  • Streamed LIVE from MIX08 - Scott Guthrie
  • Streamed LIVE from MIX08 - Dean Hachamovitch on IE8 (download ie8 beta)
  • Steamed LIVE from MIX08 - Ray Ozzie in Keynote 
  • ASP.Net MVC Preview 2
  • Silverlight 2 Beta 1 and Expression Blend 2.5 March Preview (links to runtime, vs2008 tools, epxression betas, sdks)
  • Deep Zoom in Silverlight 2
  • I missed the discussion of the one DATA related thing because of a phone call! "SQL Server Data Services: Microsoft announced a preview of SQL Server Data Services, a building block service designed for developers and businesses that need scalable, easily programmable and cost-effective data storage with robust database query capabilities. " Sheesh. Roger Jennings has blogged about this particular piece.

    Wednesday, March 05, 2008 3:42:26 PM (Eastern Standard Time, UTC-05:00)  #     |  Comments [1]  | 
     Friday, February 29, 2008

    Scott Guthrie has written about Using Expression Blend with Silverlight 2.0 in this blog post.

    I just wanted to highlight one of the screenshots from his blog post.

    Ooooh - look at ALL of those controls!!!

     

    Friday, February 29, 2008 5:38:58 PM (Eastern Standard Time, UTC-05:00)  #     |  Comments [2]  | 
     Friday, February 22, 2008

    This morning, Scott Guthrie has finally made public the list of features that we will see in Silverlight 2.0. He also include links to EIGHT tutorials all at once, rather than waiting for them blog post by blog post.

    Scott says "We are shortly going to release the first public beta of Silverlight 2". All bets are on the obvious: at MIX08 in a few weeks.

    Among the new features are

    • a bevy of built-in controls (even controls for databinding)
    • Support for WCF (goodbye to the hacks we have had to perform so far)
    • Cross domain support (hip hip hooray!)
    • LINQ to XML support (more hoorays - now I don't have to send things off to a web service to leverage LINQ to XML)

    The first beta will be about 4MB and take a whopping 4-10 seconds to install.

    See Scott's post for all of the juicy details and the links to the 8 tutorials.

    Friday, February 22, 2008 12:30:51 PM (Eastern Standard Time, UTC-05:00)  #     |  Comments [0]  | 
     Tuesday, February 05, 2008

    Matthieu Mezil is presenting on Entity Framework and LINQ (and VSTO) at next week's first (?) .NET event in Paris: TechDays 2008.

    I wanted to see what else was going on and found the website (by BrainSonic) and boy is this a fantastic Silverlight implementation. Even if you don't know French, I highly recommend checking out the website, if for no other reason than to be inspired!

    This is just but a small tidbit. After searching for Mezil, it spun (literally) these three items on to the calendar.

    There's more, but I'll let you go play with it yourself.

    Matthieu has been building up his EF expertise as well as using the forums as a means to challenge himself to learning more and sharing what he's learned.

    Tuesday, February 05, 2008 9:22:00 AM (Eastern Standard Time, UTC-05:00)  #     |  Comments [5]  | 
     Thursday, January 31, 2008

    In the TabletPC SDKs and in WPF it's very easy to take an ink image and save it to an image format - BMP, JPG, etc.

    Then came Silverlight and the InkPresenter and naturally I wanted to do the same. But it wasn't so easy.

    Silverlight itself isn't bogged down with that functionality. So you first need to get the XAML representation of the Ink and send it to a service where either the TabletPC SDK or the WPF APIs are available. Even then you are not home free because the Silverlight ink is not quite the same as either of the other two. So you then need to extract data from the XAML representation of the Silverlight ink and create a new object for whichever API you choose.

    This was all done in Silverlight 1.0. I haven't pulled this into Silverlight 1.1/2.0 yet, but it should all be the same and you still have to do the conversion on the server side. THe only difference of course, is the javascript needs to be converted to .NET code on the client side.

    Even then, there is still some more trickery because there is something strange with using the width from the Silverlight object and I spent hours just experimenting with getting the proportions to display properly in the image. I also spent a lot of time struggling with the colors because the javascript output of the color values doesn't line up with what WPF wants. You'll see in the code comments all of the conversions going on.

    Once I had all of that worked out (and this represents hours of effort) there were still some issues. Luckily, Stefan Wick, who is the ultimate guru on this topic and finally has a blog - hoorah!, was able to set me straight (and trim some  of my code down significantly).

    I hadn't thought much of this nor, apparently had anyone else, until someone recently emailed asking me how I did it so that he can use it as part of a solution in a competition. (I hope that the requirements of the competition don't say anything about original work!), so I thought I would blog the steps.

    1) Convert the InkPresenter data to XAML . This does two things. FIrst it enables you to serialize it and pass it to a web service and secondly, it is the lowest reasonable common denominator for sharing between different objects. This javascript code comes from Gavin Gear.

    This javascript code reads through the StrokeCollection property of an InkPresenter and builds up a string of xml that is the XAML representation of the StrokeCollection. You could also take the resulting string and pass it to CreateFromXAML to recreate the Silverlight StrokeCollection object.

      if (strokeCollection.Count>0)
      { 
       var xaml = "<StrokeCollection>";
       if (strokeCollection != null)
       {
        for (var i = 0; i < strokeCollection.Count; i++)
        {
            var stroke = strokeCollection.GetItem(i);
            if (stroke.Name>"")
              xaml += "<Stroke Name='" + stroke.Name + "'><Stroke.DrawingAttributes>";
            else
              xaml += "<Stroke><Stroke.DrawingAttributes>";
            xaml += "<DrawingAttributes ";
            xaml += "Color='" + BrowserColorConverter(stroke.DrawingAttributes.Color) + "' ";
            xaml += "OutlineColor='" + convertColorToHexString(stroke.DrawingAttributes.OutlineColor) + "' ";
            xaml += "Width='" + stroke.DrawingAttributes.Width + "' ";
            xaml += "Height='" + stroke.DrawingAttributes.Height + "' ";
            xaml += "/></Stroke.DrawingAttributes>";
            xaml += "<Stroke.StylusPoints>";
            for (var j = 0; j < stroke.StylusPoints.Count; j++)
            {
                var stylusPoint = stroke.StylusPoints.GetItem(j);
                xaml += "<StylusPoint X='" + roundToTwoDecimalPlaces(stylusPoint.X) + "' Y='" +
    roundToTwoDecimalPlaces(stylusPoint.Y) + "' />"; } xaml += "</Stroke.StylusPoints></Stroke>"; } } xaml += "</StrokeCollection>";

     

    2) Pass this string to a web service method that will do the following to it

    3) Create a WPF InkObject from the XAML. Now that I'm in the web service, I can use .NET code. Phew. Note that I did this before I knew how to use LINQ to XML so I struggled through XPath to get this. Watch for an upcoming MSDN Mag article that will have updated code.

          private static StrokeCollection InkObjectfromXAML(XmlNode StrokeColl)
          {
              StrokeCollection objStrokes = new StrokeCollection();
              XmlNodeList strokeElements =
              StrokeColl.SelectNodes("Stroke");
              foreach (XmlNode strokeNodeElement in strokeElements)
              { 
    
                  //step 1: create a new stroke from the stylus point elements in the XAML
                  XmlNodeList stylusPointElements =
                      strokeNodeElement.SelectNodes("./Stroke.StylusPoints/StylusPoint");
                  XmlNode drawAttribs = strokeNodeElement.SelectSingleNode("./Stroke.DrawingAttributes");
                  //points node is sent to GetStrokePOints method to convert to a type 
    //that can be used by the new stroke
    System.Windows.Input.StylusPointCollection strokeData = GetStrokePoints(stylusPointElements); Stroke newstroke = new Stroke(strokeData); //step 2: grab color metadata about stroke from the xaml //color is a hex value //the stroke object requires a System.Windows.Media.Color type //following code performs the conversion string mycolor = drawAttribs.FirstChild.Attributes["Color"].Value; System.Drawing.Color drwColor = System.Drawing.ColorTranslator.FromHtml(mycolor); //build the new color from the a,r,g,b values of the drawing.color System.Windows.Media.Color newColor = new System.Windows.Media.Color(); newColor.A = drwColor.A; newColor.R = drwColor.R; newColor.G = drwColor.G; newColor.B = drwColor.B; //Step 3: extract width data from xaml, convert to int int myIntWidth; bool parseSuccess = int.TryParse(drawAttribs.FirstChild.Attributes["Width"].Value,
    out myIntWidth); //Step 4: apply width & color to stroke //some really wierd unexplainable transformations that I had to get
                  // around until the final images looked right.
    if (myIntWidth == 3) newstroke.DrawingAttributes.Width = 1.5; else newstroke.DrawingAttributes.Width = 2; newstroke.DrawingAttributes.Color = newColor; //Step 5: add stroke to the stroke collection objStrokes.Add(newstroke); } return objStrokes; }
        //This method (called from the method above, is an abstraciton of some sample code from Microsoft
         private static System.Windows.Input.StylusPointCollection GetStrokePoints(XmlNodeList stylusPointElements)
            {
    System.Windows.Input.StylusPointCollection pointData = new System.Windows.Input.StylusPointCollection();
    
                //The object requires HiMetric point values, create multiplier for conversion
                double pixelToHimetricMultiplier = (2540d / 96d) / 100;
    
                foreach (XmlNode stylusPointElement in stylusPointElements)
                {
                    string xStr = stylusPointElement.Attributes["X"].Value;
                    string yStr = stylusPointElement.Attributes["Y"].Value;
    
                    //x and y are in pixels, we need to multiply them to get them into HIMETRIC
                    //space, which is what the InkAnalyzerBase expects
                    int xInHimetric = (int)(System.Convert.ToDouble(xStr) * pixelToHimetricMultiplier);
                    int yInHimetric = (int)(System.Convert.ToDouble(yStr) * pixelToHimetricMultiplier);
                    pointData.Add(new System.Windows.Input.StylusPoint(xInHimetric, yInHimetric));
                }
    
                return pointData;
            }
    Now we have an inkObject that WPF will be happy with!

    4) Convert WPF Ink to PNG format bytes This is with a BIG thanks to Stefan - we need to start a separate thread to do the conversion from WPF Ink ojbect to PNG. That conversion happens inside the thread. Also, thank to his deep understanding of the ink object, Stefan was able to accomplish in a much smaller amount of code what I had achieved in about 3 times as much code. I was definitely doing loop-dee-loops, but it was the best I could come up at the time.

    Note that I am not saving to an actual file here, just creating the bytes because my goal was to store that in a database.

       private static void ThreadforConverttoPNG()
       {
        Thread t = new Thread(new ThreadStart(ConverttoPNG));
        t.SetApartmentState(ApartmentState.STA);  
    
        // Start ThreadProc.  Note that on a uniprocessor, the new 
        // thread does not get any processor time until the main thread 
        // is preempted or yields.  Uncomment the Thread.Sleep that 
        // follows t.Start() to see the difference.
        t.Start();
       }
       private static void ConverttoPNG()
       {
        //I had originally achieved this with a LOT more code. This is Stefan's more trimmed down method
    
        //create temporary InkCanvas
        InkCanvas inkCanvas = new InkCanvas();
        inkCanvas.Strokes = strokes;
        //render InkCanvas to a RenderBitmapTarget
        Rect rect = inkCanvas.Strokes.GetBounds();
        RenderTargetBitmap rtb = new RenderTargetBitmap((int)rect.Right, 
    (int)rect.Bottom, 96d, 96d, System.Windows.Media.PixelFormats.Default); rtb.Render(inkCanvas); //endcode as PNG BitmapEncoder pngEncoder = new PngBitmapEncoder(); pngEncoder.Frames.Add(BitmapFrame.Create(rtb)); //save to memory stream System.IO.MemoryStream ms = new System.IO.MemoryStream(); pngEncoder.Save(ms); ms.Close(); strokeBytes= ms.ToArray();    }

    5) My next step was actually to store the bytes into a database. I wasn't actually saving out to a file. But to do that is simple. System.IO.File lets you create a new file on the fly from a byte array.

       System.IO.File.WriteAllBytes("C:\\myfile.png",strokeBytes); 

    So, those are all of the pieces from converting a silverlight inkpresenter image to an image file.

    Thursday, January 31, 2008 10:06:29 AM (Eastern Standard Time, UTC-05:00)  #     |  Comments [0]  | 
     Wednesday, October 31, 2007
     Tuesday, October 30, 2007

    I spent a lot of time coding in javascript for silverlight 1.0 and am having fun now getting back to managed code with 1.1. I'm even doing it all in C#, but the main reason is because I  have a lot of nearly reusable javascript code and it's just easier to port that to C#.

    However, as usual, I am just diving head first and not doing too much advance research. Two things I learned the hard way:

    Silverlight does not yet support LINQ
    A few months ago, I spent bunch of time buliding a beatiful LINQ to XML method to build up some XAML by hand only to discovere when I tried to run it, that it failed. I looked around and discovered that LINQ support was not there yet. Oops! But it was my first time using LINQ to XML to build an XML document, so what I learned in the process was not a waste by any means.

    Silverlight does not yet support WCF
    I built a very nice WCF service, with composite types and everything only to learn (when I went to add service reference to my SL client) that it's not supported yet. There are a few workarounds, [here on the sliverlight forums] and [here in Luis Abreu's blog], but since this particular code will be for a conference demo and I don't want to add any extra layers of complexity, I will just go back to ASMX for this one.

    Tuesday, October 30, 2007 11:25:21 AM (Eastern Standard Time, UTC-05:00)  #     |  Comments [0]  | 

    I spent a lot of time coding in javascript for silverlight 1.0 and am having fun now getting back to managed code with 1.1. I'm even doing it all in C#, but the main reason is because I  have a lot of nearly reusable javascript code and it's just easier to port that to C#.

    However, as usual, I am just diving head first and not doing too much advance research. Two things I learned the hard way:

    Silverlight does not yet support LINQ
    I spent bunch of time buliding a beatiful LINQ to XML method to build up some XAML by hand. But it was my first time using LINQ to XML to build and XML document, so what I learned in doing that was not a waste by any means.

    Silverlight does not yet support WCF
    I built a very nice WCF service, with composite types and everything only to learn (when I went to add service reference to my SL client) that it's not supported yet. There are a few workarounds, [here on the sliverlight forums] and [here in Luis Abreu's blog], but since this particular code will be for a conference demo and I don't want to add any extra layers of complexity, I will just go back to ASMX for this one.

    Tuesday, October 30, 2007 11:25:16 AM (Eastern Standard Time, UTC-05:00)  #     |  Comments [0]  | 
     Sunday, October 28, 2007

    Yet another Flash driven advertisement (here are some others i've blogged about in the past) that uses annotation. Below is a screencast of me playing with this Notes ad (with a mouse, not a stylus). You can do this in Silverlight 1.0 and 1.1 with the InkPresenter. I'll be giving a session on Annotating in Silverlight as part of the Mobile Connections show during the big DevConnections conference next week (Nov 5 - 8) in Las Vegas.

    Sunday, October 28, 2007 3:11:28 PM (Eastern Standard Time, UTC-05:00)  #     |  Comments [0]  | 

    This is probably a temporary problem as I'm working with an alpha and a beta, and therefore my fix is a  probably a temporary hack. I always have to remember how to get XAML intellisense to work whenever I start a new Silverlight project. Here's how to do it.

    [A New DevLife Post]

    Sunday, October 28, 2007 11:30:11 AM (Eastern Standard Time, UTC-05:00)  #     |  Comments [0]  | 
     Thursday, October 25, 2007

    The fall DevConnections is coming up in another 10 days (Nov 5-9) in Las vegas.

    It looks like they will have about 5,000 attendees again, like last year which is amazing.

    I will be doing a variety of talks.

    One that i'm especially looking forward to will be teaming up with John Sudds from the Internet Explorer team to present on embedding Ink-Enabled Win Forms controls into ASP.NET 2.0 pages. This will be part of the Microsoft Day session for Mobile Connections. John brings a new level of expertise to the work I have done in this area and solved some problems I was never able to get around. John will be the demo god in this session and i get to do my favorite thing: Talk!

    I will also be doing a talk about Annotating with Silverlight as part of the Mobile COnnections show. Don't let this fool you. Annotating in Silverlight, while best on a tabletpc, also works  nicely on regular pcs and on Macs - anywhere that you can run Silverlight. If you haven't seen the various test apps that I have deployed on the web, you can check them out here: the Step-by-Step series and the database persistence application.

    In the ASPConnections show, I will be doing a session on ASP.NET DataBinding with LINQ which will explore many flavors of LINQ, not just LINQ to SQL.

    And then there is the Data Access track in which I will be presenting and advanced talk on Entity Framework - Real World Entity Framework with a focus on multi-tier apps. John Papa will precede this talk with two intro type talks.

    Lastly, I will be a presenting a post-conference 1/2 day (9am-12pm) workshop on guidance for accessing data in .NET 3.5. We now have ADO.NET, LINQ to SQL and three ways to query data in Entity Framework. There will be a number of entity framework and LINQ to SQL talks during the main conference, so this session is aimed at comparing and contrasting them and providing guidance on when it makes sense to use each one.

    There's still room to sign up! http://www.devconnections.com   

    Thursday, October 25, 2007 2:49:12 PM (Eastern Standard Time, UTC-05:00)  #     |  Comments [0]  | 
     Sunday, October 07, 2007

    I wanted to create a demo of Astoria Data Services being used in a Silverlight app for my ReMix07 Boston session on Tuesday. i have created a little screencast of it in action. Read more here...

    Saturday, October 06, 2007 11:19:50 PM (Eastern Standard Time, UTC-05:00)  #     |  Comments [4]  | 
     Sunday, September 16, 2007

    Loren Heiny has been working on a cool Silverlight annotation app to user Silverlight and a stylus to do Google and Technorati searches. It's called SearchTip and is live on TabletPC Post.

    There is a lot that is really interesting about this. (And it's visually appealing too!) First of all, he has a YouTube video where he compares using this (earlier version) on a Mac to using Inkwell on the Mac (when you have a tablet ala Wacom attached to the Mac) and demonstrates the superiority of Microsoft's handwriting recognition. I was lucky enough to attend an SDR at Microsoft a few years ago where the man who ran the whole reco team explained to us how they made it all work. I can't imagine anybody being able to come close to their investment or acheivement with handwriting recognition, so it was great to see Loren being able to really compare apples to apples (no pun originally intended, but oh well!)

    Next is the fact that Loren is doing handwriting recognition from the InkPresenter in Silverlight. Not an easy feat. Once the reco is done, the result can get passed to a google service and voila you get your results displayed.

    Loren has done some amazing work with the Tablet APIs for a number of years and always thinks out of the box. So I love that he's taking his ideas and applying them to Silverlight.

     

    Of course, you don't need a tabletpc to draw in silverlight, but as awesome as the recognition is, I don't think it's fair to ask it to recognize mouse drawn handwriting. But it's not bad. Reco returns a list of guesses, sorted by best to worst. Here I'm using an earlier version which does google searching and trying it with my mouse on a regular (non-tablet) desktop.

    So you can click on the guess (I clicked on Steins) and it will show you the next guess on it's list. Heinz was next, then a few more clicks (just to see) got me off the track. oops. This is not a reflection of the reco or of Loren's app. I'm only playing around with the mouse for fun (and laziness since my tablet is upstairs.) So while the reco may not be great when you aren't using a stylus which has about 10 times the resolution as a mouse, Silverlight's ability to collect the ink data from the mouse is still pretty impressive.

    You can see Loren doing this. and how impressive it truly is using a Tablet, in his YouTube demo video.

    You can clear your writing with the x, and of course, when you have the correct reco displayed, click Search.

    Sunday, September 16, 2007 9:48:13 PM (Eastern Standard Time, UTC-05:00)  #     |  Comments [1]  | 
     Thursday, September 13, 2007

    I have dynamically generated XAML in a few of my apps. It's not easy to debug so I wrote a post sharing how I go about tracking down problems that might be in this code.

    [A New DevLife Post]

    Thursday, September 13, 2007 12:20:28 PM (Eastern Standard Time, UTC-05:00)  #     |  Comments [0]  | 
     Wednesday, September 12, 2007

    Hey, so I'm not a walking encyclopedia.

    I thought it would be cool to try to build an xml file from a Silverlight object - namely the StrokeColleciton of an InkPresenter.

    I coded it up in what I thought was a very nice way:

       XElement XMLStrokes = new XElement("StrokeCollection");
       //create stroke then add to collection element   
       XElement mystroke;
       foreach (Stroke s in mystrokes)
       {
        mystroke = new XElement("Stroke",
         new XElement("Stroke.DrawingAttributes",
          new XElement("DrawingAttributes",
            new XAttribute("Color", s.DrawingAttributes.Color),
            new XAttribute("OutlineColor", s.DrawingAttributes.OutlineColor),
            new XAttribute("Width", s.DrawingAttributes.Width),
            new XAttribute("Height", s.DrawingAttributes.Height))));

        //create points separatly then add to mystroke xelement
        XElement myPoints = new XElement("Stroke.StylusPoints");
        foreach (StylusPoint sp in s.StylusPoints)
        {
         XElement mypoint = new XElement("Stylus Point",
          new XAttribute("x", sp.X),
          new XAttribute("y", sp.Y));
         myPoints.Add(mypoint);
        }
        mystroke.Add(myPoints);
        XMLStrokes.Add(mystroke);
       }

    It compiled fine, but then the strangest thing happened. The code would never get called. If I put it in a method and had a click event call the method, the method would not get hit. I put it in a new static class but still it did not get hit. Then I put the code right in the click event and then the click event stopped getting hit.

    I thought for sure it was me being stupid with C#. But finally I had a new idea and I googled "LINQ to XML" and Silverlight and the first hit was a post by Fabrice Marguerie saying that LINQ to XML was not supported in Silverlight, with a link to a post by Aaron Dunnington on the XML team.

    Not supported, eh? Well, it's just not quite yet. it'll be there. (I knew that from reading Aaron's post, but totally neglected to point that out. Thanks for Scott Guthrie's reminder in the comments.) Either way, it sure had a funny way of showing it. Sheesh!

    I suppose I could put it into a WPF project and test it (I still don't know if my logic is correct) but I've got better things to do at the moment.

    Note: I did think of using a webservice for this, but a StrokeCollecton is not serializable, so it would be redundant to find another way to get it across the pipe just to see if I can pull it off in LINQ to XML while still in the context of a Silverlight app. I'll just be patient.

    Wednesday, September 12, 2007 8:32:55 PM (Eastern Standard Time, UTC-05:00)  #     |  Comments [1]  | 
     Sunday, September 09, 2007

    Up until now, i've done all of my exploration of annotation in Silverlight using WPF/E and then the 1.0 bits. I finally took my first dip into Silverlight 1.1 today and wanted to see what it took to recreate a simple InkPresenter example using the .NET runtime. Here is what I found.

    [A New DevLife Post]

    Sunday, September 09, 2007 5:47:19 PM (Eastern Standard Time, UTC-05:00)  #     |  Comments [0]  | 
     Wednesday, September 05, 2007

    Scott Guthrie announces the official release of Silverlight 1.0 (this is the version that you code up in javascript) as well as Microsoft's partnership in bringing the Linux support that Miquel de Icaza fronted into the Microsoft fold.

    Read more and see links to existing big-name websites using Silverlight 1.0 on Scott's blog.

    Wednesday, September 05, 2007 10:27:20 AM (Eastern Standard Time, UTC-05:00)  #     |  Comments [0]  | 
     Monday, August 06, 2007

    I have updated two of my demo Silverlight apps which broke with the RC version of Silverlight that came out last week.

    The little embedded drawing surface at the top of this blog has been fixed along with my more full blown annoation application.

    All of the changes I made were listed in the "What Changed Between Beta and RC" topic in the Help file that comes with the SDK. The one that had me confused for a while was switching the "\" to "/" in the xaml where I had images in subfolders etc. It confused me because I somehow skipped over it in the list and the error that it threw the error "2210: AG_E_INVALID_ARGUMENT" which didn't tell me too much.

    You can read more about updating your Silverlight apps to work with the Release Candidate version here.
     

    Monday, August 06, 2007 5:07:02 PM (Eastern Standard Time, UTC-05:00)  #     |  Comments [0]  | 
     Wednesday, August 01, 2007

    Well, I didn't pay attention and all of my silverlight apps are broken. But fixing them up was pretty easy (except for one lingering issue I'm having with CreateFromXaml and ink presenter stroke data). Here's a post to point you to what you need to updates your apps from Beta to RC and also a great resource for Silverlight Error Codes.

    [A New DevLife Post]

    Wednesday, August 01, 2007 2:10:00 PM (Eastern Standard Time, UTC-05:00)  #     |  Comments [0]  | 
     Saturday, July 14, 2007

    I don't have a Mac, but while I was working on my Silverlight annotation tests, I had a few friends try them out on Safari on their Macs and they reported that it just didn't work at all.

    Now that we have a Windows version, I finally did a few tests myself.

    At first, I was being prompted to install (the already installed) Silverlight.

    This post by Jeremy Boyd helped me elimitate that problem. When the page first appeared the spot where my embedded Silverlight goo should be was all white. But I saw in this post by Tim Heuer (Tim suggests another solution for the seemingly uninstalled Silverlight, but that one didn't work for me), that resizing the browser helped and indeed, it did. I was surprised to actually see my solution appear!

    Then I started clicking on the images on the right. Nothing happened. But when I inadvertently resized the browser again, the images did appear.

    I was actually able to do a little drawing on the screen (not the one above!) but it wasn't much fun. Draw a stroke. Resize. See the stroke I just drew. Etc.

    So it's close, but not there yet. I don't think there's much I can do but wait for some change to this  beta version of Silverlight or some change to this beta version of Safari for Windows.

    Saturday, July 14, 2007 8:25:53 PM (Eastern Standard Time, UTC-05:00)  #     |  Comments [0]  | 

    One of the issues that held me up a for a while when I was working on my SilverInk Silverlight annotation app, was a difference between some color encoding between IE and Firefox. I was very lucky to discover a seemingly unrelated blog post that held the magic key to solve my problem. Read more here...

    [A new DevLife post]

    Saturday, July 14, 2007 8:06:34 PM (Eastern Standard Time, UTC-05:00)  #     |  Comments [0]  | 
     Thursday, July 12, 2007

    Pepole are leaving messages in the drawings of my Silverlight tests. One was interesting and doesn't need to be repeated. :-)  Two other asked:

    1) Are you going to post the source?

    Not yet.

    2) What business purpose?

    This is part of the reason I am not posting the source yet. :-) Second, what business purpose is YouTube or Facebook?

     

    Thursday, July 12, 2007 4:12:12 PM (Eastern Standard Time, UTC-05:00)  #     |  Comments [2]  | 
     Wednesday, July 11, 2007

    I've been banging away with javascript and Silverlight for a while, trying to implement the next step of the idea I am aiming for with silverlight.  You can read about it here or just go right to the site and add some artwork of your own. As you can see from some of my tests, no talent is required! :-)

    [A New DevLife Post]

    Wednesday, July 11, 2007 7:57:10 PM (Eastern Standard Time, UTC-05:00)  #     |  Comments [0]  | 
     Friday, July 06, 2007

    I opened up the Amazon.com site today and was quite startled to see this:


    But when I viewed the source, I saw that rather than just one DIV that embedded all of this functionality (which is what I would expect from a Silverlight object) , there was a ton of html and script pulling this off, including a reference to:

     new SWFObject("http://g-ec2.images-amazon.com/images/G/01/s9-ampaigns/MultiPackCarousel._V19505961_.swf

    SWF spells Flash. Oh well.

    Friday, July 06, 2007 3:48:14 PM (Eastern Standard Time, UTC-05:00)  #     |  Comments [0]  | 
     Sunday, July 01, 2007

    Last time I wanted to play with using videos as a source for Silverlight media, I found that Silverlight's "WMV only, thank you" limitation put the kibosh on my plans. YouTube and Yahoo are Flash and at the time Soapbox was password protected. Soapbox's latest beta removed the permissions requirement on June 1 so I finally found some time today to go digging around to see if I could now use those videos as a source for dynamic embedding in silverlight. I was a little bummed to see that the the videos are also flash. Here's what you get when you request embed script for a particular video:

    <embed src="http://images.soapbox.msn.com/flash/soapbox1_1.swf" quality="high" width="432" height="364" wmode="transparent" type="application/x-shockwave-flash" pluginspage="http://macromedia.com/go/getflashplayer" flashvars="c=v&v=30dd604f-e0f6-498e-a24c-e3b65c7d2452" ><embed><br /><a href="http://soapbox.msn.com/video.aspx?vid=30dd604f-e0f6-498e-a24c-e3b65c7d2452" target="_new" title="Microsoft® Silverlight">Video: Microsoft® Silverlight</a>

    Flash flash flash

    I tried pasting in the url anyway for the videos just in case, but of course, it doesn't work.

    bah!

    Soapbox is still a beta, and does have great features, so hopefully (presumably?) there will be more options in the future.

    Sunday, July 01, 2007 4:00:40 PM (Eastern Standard Time, UTC-05:00)  #     |  Comments [0]  | 
     Friday, June 22, 2007

    Miguel de Icaza and team pulled it off in 21 days! Read more here...

    [A New DevLife Post]

    Friday, June 22, 2007 10:44:56 AM (Eastern Standard Time, UTC-05:00)  #     |  Comments [0]  | 

    As my young co-workers at a former job would say: "chickety-check it out"! www.thedatafarm.com/blog

    (I'm still trying to work out the issue of it not showing when you are looking at an individual post.)

    Friday, June 22, 2007 7:44:35 AM (Eastern Standard Time, UTC-05:00)  #     |  Comments [0]  | 
     Thursday, June 21, 2007

    The Mobile team is at it again. They have written a converter to take Journal notes and convert them into an interactive Silverlight page. You can read about it on the Mobile dev center and download the converter application. There are two live demos of it here on my own website where I have hosted their sample and one of my own. (Click on the images below to go to the samples.) Note that mine seems to have stretched a bit because I created it on a lower resolution computer.

    Thursday, June 21, 2007 8:45:56 PM (Eastern Standard Time, UTC-05:00)  #     |  Comments [2]  | 
     Monday, June 04, 2007
    This was easier than I expected! Go ahead, draw in my blog post! :-)

    (note - If you do not see the drawing surface it's because this doesn't seem to work when the blog post is viewed individually. View my entire Silverlight category and it will