Monday, February 8, 2010

Pimping

Just taking a moment to pimp my graphic designer's new blog.

http://aimee-design.com/notebook/

While the subject of graphic design for Silverlight using Expression may not be directly related to development, it is directly related to making the most of Silverlight. G-d knows how crappy my web applications would look (Silverlight or no Silverlight) without the expertise of a talented artist! Additionally, I've found that putting together the UI in Blend is a hundred times easier than trying to work just from the XAML in Visual Studio's Design View (especially since the graphical design view usually shows you exactly nothing), so we frequently teach each other little tricks on how to make things work from the design side.

If you have an interest in UI development for Silverlight and/or know any graphic designers who do, feel free to pass it along. She's just getting started with the blog but I suspect there will be plenty of good stuff here.

Friday, February 5, 2010

FAILBOAT: IE 8 and Silverlight debugger - "no breakpoints have been loaded"

Awhile ago one of my newhire devs informed me he could not debug our Silverlight application. I sent him on a google-fu quest to figure out why and get it working, since not being able to debug is a Pretty Big Deal. He was not able to find a solution to the problem but being a resourceful fellow he found a workaround which involved a single test page that opened the Silverlight window in-situ instead of popping up a new one.

Fast forward to yesterday, where your gentle blogger was having issues with the )(#%)@*(#*(@% application known as Software Planner, a dinosaur of a bug tracking system built in *gags* Classic ASP, that has truly abyssmal usability and hangs constantly. I was told that upgrading my IE to version 8 (I was on 7) would magically solve all my problems with that bit of software "engineering". Well, it didn't, and it created a world of new ones.

Suddenly, I can't debug my Silverlight application either. I spend several hours trying every suggestion I can find in the blogosphere before I come across a post asking it the problem might perhaps be related to IE8, which had just been installed.

Aha! So I uninstalled IE8, and guess what? My problems mysteriously vanished and my debugger is happily munching Silverlight grass again.

I wonder how many hours of people's productivity has been wasted on this.

The moral of this story is, until they fix this, if you are a Silverlight developer, run, don't walk, away from IE 8 as fast as your little feet can carry you.

*Note - I use Firefox and/or Chrome for my personal browsing pleasure. But since most people use IE, I figure I ought to be testing on that. I hadn't even noticed I didn't have the latest version until my coworker mentioned it.

I love Silverlight, but this IE8 bug gets a failboat award from me big time.

Tuesday, February 2, 2010

Call for assistance

This is a long shot but my google-fu has been weak on these subjects.

1) database access from native C++ using OLE DB without wiring it into any UI or using a template. I want to open my own connections, send my own sql queries and traverse my results without creating strongly typed objects as the templates do. This will run from a dll exposed by some sort of service.

(The most promising thing I've found is the SQLAPI from www.sqlapi.com, I am going to evaluate this and see if it meets my needs or at the very least teaches me something, but it's not free.)

2) creating win32 dlls (not MFC) from native C++, how to expose the properties and methods and get them to export a lib file that can be referenced elsewhere. How to expose "endpoints" for socket connections that can access these.

I have been giving myself a crash course in native unmanaged C++ using Ivor Horton's Beginning C++ for VS 2008, basically ignoring all of the managed C++/CLI stuff to keep from confusing myself and it has been going very well except that about halfway through the book he moves into MFC and windows development and assumes everything you want to do is in that context, so the above two topics aren't handled well at all. If for some reason you want to do MFC or WinForms development using C++ it really is a great book though.

I looked for books that were more advanced on these topics and they are mostly from 8+ years ago, so I'm not sure how pertinent they will still be (although admittedly native C++ isn't exactly new technology).

Any thoughts or suggestions from the peanut gallery?

Tuesday, December 8, 2009

Good stuff!

Some previews of what is to come with Silverlight 4 that are of keen interest to me are found here.

Better databinding with formatting, nullvalue and invalid binding handling. And more...I even heard rumors that binding to collections with an indexer will be natively supported, but I heard that elsewhere.

Additionally, if you haven't worked with Common Table Expressions in your SQL database, you really need to know about them. They make all sorts of things easier including paging and complex combinations of queries. Here's a nice introductory article.

Wednesday, November 25, 2009

Popups and Borders, Oh my!

In Silverlight there is a "Popup" control which is designed to be a popup. You open and close it using the "IsOpen" property. It is a container like border, grid, etc. In Blend it sometimes decides to be open and sometimes not (I noticed this odd behavior both in Blend 2 and 3).

One big downside I found to using the Popup control aside from the Blend oddness is its drag behavior is very choppy.

When you add the MouseDragElementBehavior to a Popup, and then try to drag it at runtime, it jumps around before stopping where you dragged it. YUCK.

Thus I really don't see any advantage to using the Popup over using a Border instead. When the MouseDragElementBehavior is applied to a Border, its movement is as smooth as a baby's tushie. From a code perspective you just have to control the Border's Visibility property instead of using IsOpen. Not a huge change.

If anyone knows some advantage of the Popup that I'm missing, please do tell.

Monday, October 26, 2009

DataGrid & Dynamic Font Loading

Unicode font packages are HUGE. Like 33MB huge. This interferes with compiling your .xap file if you are using the "supported" method of using the FontManager to include the font in your Silverlight assembly. By interferes, I mean anywhere from 25-75% of the time you get an "Out of memory" exception when you try to compile. Reboot and the problem goes away for awhile, but not long.

For months I've had on my "to-do" list to pull the font file out and start loading it dynamically using the WebClient, but I had so many features in my "to-do" list that the users can actually see that I kept delaying it. Well, today I got so fed up with the out-of-memory shuffle that I decided to put my foot down, stop working on everything else, and git-r-dun.

I decided to use the unicode font only where the potential for dynamic data exists and to use a static font for static data. Find-replace for the win. However, there is a bit of drudgery associated with updating the FontSource for each framework element that must use the dynamically loaded font. And, when it came to updating the Silverlight ToolKit DataGrid objects I was using... a small stumbling block. The DataGrid and its DataGridColumns do not expose the FontSource. They expose the FontFamily, but that's only half the work.

So here's how I handled it - I replaced all my DataGridTextColumns with DataGridTemplateColumns and for each one, defined a custom CellTemplate containing a TextBlock. I set the Text using the normal Binding Path methodology and defined a handler for the Loaded event of the TextBlock. In this Loaded event, I set the FontSource.

You might recognize this trick from my dynamic ToolTip post... that's where I got the idea. (I also tried binding the FontSource property of the TextBlock in the XAML but that caused a Big Fiery Ball Visible From Space.)

Maybe prujohn or some of my other Silverlight 3 savvy readers may know if there is a better way to do this in Silverlight 3 (which I should be able to upgrade to any time now when our Blend 3 licenses arrive...waiting...waiting...) or whether I should continue to make this change all over my application (spending a heck of a lot of drudgerous time in so doing)?

Happy Monday,
Anye

Monday, October 5, 2009

Abstract base classes

A short fyi - Expression Blend (ETA: Blend 2) can't handle abstract base classes.

Scenario: I have two pages A & B that I need to be possible "source" pages for another page - I could either have both implement an interface or use inheritance. I choose inheritance for various reasons (mainly involving shared functionality between A & B), and want each class to have an UpdateAfterDone() type method to be called by the 2nd page to update the 1st with its results. I tried having both A&B inherit from an abstract class that defines an abstract method UpdateAfterDone(), and everything was hunky dory until I tried to open A in Blend. When I switched the base class to be concrete and made UpdateAfterDone virtual, it rendered fine.

Not a show-stopper, but since I don't really have "default" functionality for UpdateAfterDone() like I do for some of the other methods I would think it would be cleaner to be abstract. If not for the shared functionality I'd use an interface instead.

Harumph.