The Stochastic Game

Ramblings of General Geekery

Posts with tag 'xaml'

    Making WPF controls double-clickable

    A common UI pattern features the ability to double-click on a control to go in “edit” mode. So for example, you have a TextBlock that shows you the name of an object, and you can double-click it to change it into a TextBox where you can edit that name. At this point, it’s easy to hook up the MouseDoubleClick event, or some other mouse event, but that’s not very MVVM-like, is it?
    Read more...

    Xaml serialization quirks and gotchas

    I recently had to build a little tool that would read its configuration from a XAML file (because XAML serialization is, most of the time, better and more customizable than standard XML serialization). The trick was that this tool had to be built on top of .NET 3.0 – not 3.5 or 4.0. And I discovered that there are a few little gotchas in .NET 3.0’s XAML serializer that I, somehow, never ran into before.
    Read more...

    Writing a custom Main() method for WPF applications

    Creating a new WPF project in Visual Studio gives you the following pretty simple application markup and code: <Application x:Class="WpfApplication2.App" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" StartupUri="Window1.xaml"> </Application> namespace WpfApplication2 { public partial class App : Application { } } Understanding how it really works, and how to supply your own custom Main() method, is just a search query away. You basically need to change the application’s build action from “Application Definition” to “Page”, create a constructor that calls “InitializeComponent”, and write your Main() by eventually calling one of the application’s “Run” method overloads.
    Read more...

    Fixing a bug can cause bugs

    Microsoft apparently fixed something in .NET Framework 3.5 Service Pack 1 that previously didn't work, or somehow worked differently. As a result, Milkify will crash if used on a machine that doesn't have this service pack installed. What you get is a XamlParseException that says that a ContentStringFormat property cannot be converted into a TemplateBindingExtension. This is because Milkify is using its own WPF skin where, among others, the check box control has a new custom template.
    Read more...

    A variation on the auto-completing WPF TextBox

    In this world of web 2.0 tagging madness, any good (or at least shiny enough) application needs a way to apply tags in a user-friendly way, namely with auto-completing text boxes. For example, the awesome Remember The Milk application has this: What if we want a similar text box in WPF that would display a drop-down list of all the existing tags that match what the user is currently typing? The answer is, unfortunately, that we need to do it ourselves… but don’t be afraid, we’ll be playing around with cool things!
    Read more...

    Almost everything you need to know about XAML serialization (part 2)

    In part one of this little simple series, we saw how to use XAML as a file format for our own custom types. However, we wanted to reduce the verbosity of XML for specifying objects with only a few properties. This can be done with MarkupExtensions. We saw that the XAML serializer is asking if our types can be converted to the MarkupExtension class. Let's give our CustomizableEngine class the ability to do that:
    Read more...

    Almost everything you need to know about XAML serialization (part 1)

    The XML serialization API in .NET is pretty cool, but if you really want your data to look hype and futuristic, you can try out XAML! XAML is not just for WPF or WF, it’s actually a generic XML-based language used to describe hierarchies of .NET objects. You can therefore use it to serialize your own stuff. However, unlike the XmlSerializer which you can twist into writing and reading any XML, the XAML serializer will conform to the XAML “standard”.
    Read more...

    XAML markup is for real men

    The Visual Studio designer for WPF is quite lame as it stands now, and although it will get a lot better when Visual Studio 2008 SP1 is released, if you're a WPF developer, you really need to know how to read and write XAML by hand, much like web developers and designers know how to read and write HTML and CSS by hand. Since you're not a wussy, what you actually want is for Visual Studio to always show a full view of the XAML markup when you open a XAML document.
    Read more...