Inherit from an abstract base class Build in your own navigation and targeting algorithms Join the arena Battle to the death That’s the idea behind this little project, RoboDojo. No, it isn’t a new idea. No, it isn’t terribly unique (Java’s RoboCode), but it sure is fun. And the domain turns out to be very […]
ElegantCode just got a whole lot smarter in the UX department with the addition of Corey and Brian. Both bring a wealth of UX knowledge from RIA Silverlight, WPF, XAML, Game Development, Animation & Design. Brian wasted no time dropping several posts here on us at ElegantCode, and I?d bet a few bucks there’s a […]
Today I found myself writing the following code: private void DoSomething(String userName) { using(var userEntry = GetUserEntryFor(userName)) if(CouldBeFound(userEntry)) { // Do something with userEntry } } private DirectoryEntry GetUserEntryFor(String userName) { // … } private static Boolean CouldBeFound(DirectoryEntry entry) { return null != entry; } Notice the combination of the if statement with the using […]
While I think agile engineering practices are step 0 in building an efficient agile team, there are few of the ?soft? practices which seem like low hanging fruit for a team that wants to grow more efficient over time. In my opinion, the most bang for the buck comes from Retrospectives. Disclaimer: I am far […]
Do you have a WPF application that just seems to be slow in some areas and have no idea on how to track it down? Enter the WPFPerf profiling tool. WPFPerf is a suite of performance profiling tools that allows you to analyze the run-time behavior or your WPF application. It can also help determine […]
This time, we’re going to try an open session. We’re all open for suggestions, but Colin suggested Fluent NHibernate or the state of ALT.NET (for more info, see here and here) which are both hot and interesting topics at the moment. But do join us next week and share some of you’re insights on any […]
So you want to use a Ribbon toolbar similar to Microsoft Word in your applications, but you don?t want to purchase one from a third party. Well if you haven?t heard already, you can get a free one directly from Microsoft. Yes, you heard me correctly, FREE, and FROM MICROSOFT. So where do you get […]
So you want to format the output of information but don’t want do it in code behind or write a value converter to do it. Well, good news, you don’t have to. You can format your data directly in XAML. How, you may be asking? New in .NET 3.5 SP1 is the StringFormat attribute.
Example 1: Lets say you want to format a double value into a currency:
Notice the “{ }” just after the StringFormat attribute? What that is doing is escaping the text after the “=” sign. You need to do this because we do not have any text directly after the “=” sign. If you don’t put the “{ }’”, strange things will happen.
And now lets say we want to place some text in front of the currency:
Since we now have text after the “=” sign we no longer need the “{ }”.
How about a date you ask:
Oh, and you want time:
What? You want to create a tooltip comprised of more than one property of an object. Well Okay:
As you can see the StringFormat attribute can be a time saver, and just make life a little easier. One thing to note is that if you use the StringFormat attribute and you bind to a property that has no value, otherwise known as null, then the text that will be displayed is “{DependencyProperty.UnsetValue}”.
Recent Comments