31 July 2008

How to dispaly HTML/rich text in Silverlight

Silverlight is intended for making applications way more that for making websites. If what you're making is more like a website (and what I'm working on definitely is), you're gonna want to put content, and if you're putting content, you're most probably putting text, and if you're putting a lot of text, you're gonna want to format it. And you've been formatting text in HTML since your early childhood, so your'e wondering how to insert this dear HTML of yours into a Silverlight application website.

You have three possibilities:

  1. Formatting text using the "Run" element.
  2. Using the HtmlTextBlock control written by Delay, which supports the tags: a, b, br, em, i, p, strong and u (but no CSS).
  3. HTML Overlay:
HTML overlay is explained here (and that's where the picture's from).

I'm trying HTML overlay today.

29 July 2008

What you can and can't in Silverlight

You can: insert a calendar in a button.

Who would want to do that anyway?

You can't: insert a link in text. Who would want to do that anyway?

You can: insert a link in a button. Now try clicking one so fast the other won't notice.

You can't: click on a control like a dumbass. At least when the VisualStateManager is involved, it raises a critical exception.

You can: control you treadmill from Silverlight. I'd exchange that for the links in the text, but it's still a nice feature to have.

You can't: inherit like a normal person. It's a bug if it's working fine.

27 July 2008

The power of a good definition.

I heard once that most arguments are about definitions. I'm actually going to argue with that, as it implies that everyone thinks basically the same, different people just label things differently. However, I agree that it is crucial to precisely define things we talk about. And today, I'm going to talk about courage.

So what is courage anyway? No one ever asks because we all "know" since preschool that courage is "like when the knight fights the dragon and he is not scared".

I did however hear a good definition of courage once. In a Disney Channel movie: "The princess diaries". (I was young and needed something to watch, okay?)

Courage is not the lack of fear but the conviction that something else is more important than fear.

The biggest difference between those two definitions? Their impact. When you have the first one in mind and you're scared of doing something, you won't find the courage to do it. You'll think "I'm not like those courageous people because I'm scared". With the second one, you chances of doing the thing you fear skyrocket, but only if it's the right thing to do. Because it doesn't really work when it comes to something dangerous and stupid. Unless it has some value for you, like impressing some people, fear will stop you and courage won't help, because it's no courage to do something unreasonable. (Okay, there a whole other discussion about the difference between "is stupid" and "is stupid to you", but I'm not going there now.)

Realizing this made me really think. Why is a children movie the only place I heard such a good definition of courage? I read, go to the church and stuff, and somehow my environment never really taught me about courage. What else did I miss?

Another example just came to my mind: humility. As the opposite of pride, it's often confused with low self-esteem: the lower you think of yourself, the more humble you are. But, don't we hate hearing "Oh, I'm so fat"? And how about "I'm an expert on this, I will take this responsibility" - isn't it a really positive attitude? So can humility be something negative? Not if you define it like St. Bernard: "a virtue by which a man knowing himself as he truly is, abases himself". The crucial part here is the truth: if you're truly an expert in something, don't deny it, others will benefit more from your skills than from a so-called humility.

I think that after centuries of focusing on humility as the opposite of pride, our society needs now more to fight the exaggerated low self-esteem, which I think is a form of pride: "it hurts me I'm so fat, because I'm supposed to be fit". Still, it's hard to find the balance between the two sides, but keeping in mind a good definition really helps.

It's amazing how values that seem so outdated can become great when you give them a bit of thought and look at them in a new way.

Yet another blog

Inspired by the many great fashion blogs out there, I just created my own one to collect all the stuff that inspires me. Less geek, less content, way more pictures, graphics, clothes and other girly stuff I wanted to spare my geekest readers. Still, everyone's invited at Lila-inspired.blogspot.com.

23 July 2008

More on learning Silverlight

Today, I'm linking you to some articles on learning Silverlight.

20 July 2008

How to learn Silverlight in 10 steps

I'm feeling like the luckiest geek on Earth. I had mixed feeling about starting work because I wanted to have some free time to learn Silverlight. And guess what - that's exactly what I've been doing at work for the last two weeks!

Here's what I started with: a strong background in programming, but mainly in ANSI C, a minimum knowledge of C#, a bit of experience in creating a GUI in Java... and that's all that's relevant, I guess. And here's what I've done so far, put in an as systematic way as I can, so if you wanna learn Silverlight too, follow me.

  1. Find out what Silverlight is and where it fits. If you're just gonna use it as a Flash replacement, there's no point.
  2. Get the tools from http://silverlight.net/GetStarted/. (You might as well learn from that website and be really happy, but for me, it's not systematical enough and I hate video tutorials, so I've been to many other places).
  3. Make a "Hello World" application to understand what is what in a Silverlight application. This tutorial is a great place to start and you can follow all the 8 parts right now for a quick walkthrough of the basic features. That's what I did, and then I googled for specific stuff I needed.
  4. Learn about the layout controls: grid, stack and canvas. Now you can add stuff to your application without wondering why they all are in the left top corner and overlap each other. And to make a more custom user interface, learn about basic geometric shapes.
  5. Learn about the basic controls: buttons, radio buttons, text boxes, and whatever you might need and is already out there ready for you.
  6. Learn about event handling.
  7. To use lists, grids and stuff, learn about data binding and data collections.
  8. Learn to make your own controls and to style them, in XAML directly or with Blender. See also this glass button tutorial.
  9. Learn to make animations: in XAML, in C#, with Blender. Why three ways? Blender produces XAML code, probably faster than you'd type it, but it's useful to understand how it works to be able to modify it. In C#, you may have problems keeping the logic separated from the presentation, but sometimes you need to create or modify animations at runtime or reuse them. Before you do too much with animations, learn about the Visual State Manager. This tutorial explains it in an excellent way, read it carefully. It has issues, unfortunately, see here.
  10. Learn about accessing the HTML DOM from managed code.
  11. Learn about networking and communication in Silverlight.
  12. Learn using isolated storage and application settings.
I've been done the steps up to number seven. You're not exactly done after number ten, there might be stuff I'm not yet aware of and there are more advanced topics like inheriting from User Control vs. Custom Control or security. You may need to improve your C#. Plus, no tutorial will ever replace experience, but if you wanna gain it, I hope I've helped you figure out how to start.

17 July 2008

I love this company!

So I'm playing with this Silverlight thing and I want User Control inheritance. I'm not asking for much, right? Inheritance in object-oriented programming? Turns out I am.

I'm making this tree. Nodes have different stuff in them, like text or a slideshow, but they're all nodes of the same big tree. Smells like inheritance, right? So I go and google "silverlight control inheritance". And end up on the official Silverlight forum.

Over there, cool quotes. An MVP says:


I don't know of any good workarounds for it at this point, I've tried a bunch of different things to get around this.

And another guy goes:

I'm surprised to see this works: (...) This is likely to be a bug. I'll redirect this to our product team.

And after another one:

This is a bug if it's working fine

I can say with all my heart: I love this company!

14 July 2008

How geeks make popcorn



Sadly, it's a hoax.

13 July 2008

Fashion goes geek

Fashion goes round and things no one would consider "hip", "cool" or whatever end up extremely fashionable. Who would have ever thought the look below could be considered fashionable?


And yet it is. For three reasons, I think. First, so many areas have already been deeply explored by fashion and in search for something new, designers have taken inspiration in the geek look. Second, fashion is about what you can't have, and in a world when teens can have more and more, there's fewer things that they can't have, but for most, there's always exclusive private school like in Gossip Girl . Third, fashion is about making people buy new stuff, and no fashionista own enough clothes in that style to try wearing it.

Seriously, who's got a fox sweater in their wardrobe? Anyone? And a hat like that? My grandma does.

Well, I like this look. But unfortunately, few people at my school watch Gossip Girl and if I dressed like that, I'd look like one of our teachers instead of a fashion-aware person. I think the geek look needs more time to settle (and leaves to fall), people around me are wearing neon brights right now.

[Picture credit]

09 July 2008

Silverlight without Visual Studio

Silverlight looks cool. Unfortunately, its development is not supported in Visual Studio Express Edition (see Silverlight.net). The good news is: you can do it without VS, all you need is a Silverlight SDK, the .net framework and a text editor. The bad news is: it's a lot of work, especially when debugging. Anyway, here is a tutorial on how to do that (with Silverlight 1.1).

08 July 2008

First day of work

The title of the post is misleading: today is my second day of work. But I was so busy on the first one that I didn't get to tell my fascinating adventures.

I had to get there after 11p.m., so I decided to learn a bit of C#. I printed made Brother print for me the advanced chapters of "C# Programming" on Wikibooks - cool and useful. That page lead me to a tutorial entitled "learning C# in 5 minutes" which I tried in the 5 minutes before going out, but I don't really feel like that made me learn C#.

And the I went to the real work. Finally. And spent the whole day preparing my workstation, whcih means mostly installing Windows XP. That went not too bad, reinstalling my systems in March was a good idea as I knew pretty well everything I had to do.

Well, and that was all on my first day. Today I installed Office and I'm gonna discuss with the boss wich project I will join and therefore what developement environment to set up.

04 July 2008

I Twitter!

Twitter. It's everywhere now. I couldn't have missed me, could it?

Basically, Twitter is like a blog, but there is a140 character limit, which makes it more suitable for some uses.

I first thought Twitter had only two uses:

  1. reporting details of your life nobody cares about, like "I just went to the bathroom and made the biggest... mistake ever reporting about it".
  2. losing weight publicly (or tracking any other goal).
And then Penelope Trunk blogged about Twitter and some people called it a "new technology". That's two very wrong things.

First, Penelope Trunk. I like reading her career advice blog, but I don't really trust her advice. She writes not to post one's naked pictures on the web - what a wisdom! A few months later, a guest blogger called "Google Guy" writes: "Those photos don’t matter as much as you think". She gives "advice at the intersection of work and life" but is getting divorced and blames it on the fact that her husband stayed at home with the kids. And she twitters:
Asking my therapist: on my blog post about kissing the farmer, should I leave the comments from my not-yet ex?
(Want some advice at the intersection of love and life? Don't let your marriage fall apart. Don't blame divorce on a single bad decision. Don't kiss when you're involved with someone else. Don't kiss a guy when all you can say about him is "the farmer". Don't give intimate details to thousands of readers. Do hide the lame stuff.)

Second, "new technology". Twitter is a bit like a blog, but with shorter posts (who forbid you to write shorties before?) and a bit like your info on your instant messenger (except it's logged better). You gotta give me a lot more to call something "new technology".

Okay, so that was me and Twitter two days ago. Until my dearest Lifehacker gave me great inspiration. I added a few Twitters on the side of the blog and found more smart uses to the thing. But the biggest thing is: I have starter my own one! It's a combination of goal-tracking, note-taking and bookmark-managing and it's dedicated to learning languages. I'm just starting the summer holidays (and work on Monday!), so I'm trying to plan language learning for this summer. I was thinking about setting up a new blog for it, like Lila Loves Yoga, but a blog is too much work, so let's all welcome the new Twitter: Lila Loves Lingos.

Are DRM dying?

Lifehacker reported that Rhapsodhy is going DRM-free. So did Amazon not so long ago. That's a lot of DRM-free music and that's music to my ears. You know how I love DRM. I wish them death: a long and extremely painful death. Well, actually, not long, and not painful for the users, but I'm sure you get my point.

02 July 2008

Geek gets new phone (and gives it up)

I recently had the opportunity to buy a new phone for a buck (even less, actually), to choose from a short list in an even shorter time. Encourage by all my positive experiences with the 770, I decided to trust Nokia and chose the Nokia 2610.

The day I got it, I had a very hard time deciding wether to switch to this phone or keep my old one. My old one has a black-and white screen and no vibrator, but I'm so used to it that I could use it with my eyes closed. The Nokia 2160, however has a few features that my old one doesn't have:

  1. A colorful screen. But that makes it harder to read in the sunshine.
  2. A thingy to connect a leash. Could be useful.
  3. Java. I know Java now, you know? I could write something. But I also know other stuff and haven't even tried programming anything for the Nokia 770.
  4. Mp3 ringtones. Cool!
  5. A compatible charger with my Nokia 770. Or so I thought. That would make one charger less to carry around, if they were the same. They're not. Now I'm really disappointed in Nokia. By the way, the cable to connect the phone to a PC is not included and is not a mini-USB like in the 770's case. Disappointed again.
All in all, I decided to keep my old phone (a Sagem my-X1 twin) and make a brother happy with this one. Brothers turned out to be unhappy about it, as nothing says "like of freedom" like "where are you right now?" or "why haven't you called?". But that's a different topic (and not a geek one).

[Picture credit]