Data See, Data Do

Mike Hillberg's Blog on Wpf and Silverlight

Browse by Tags

Tagged Content List
  • Blog Post: A Custom Storyboard Component in Xaml

    In WPF & Silverlight, a Storyboard is a collection of animations running in parallel. Not everyone likes the name “Storyboard” though. The idea behind the name was that that list of timelines running in parallel are like a list of plot lines in the plan for a movie. In any case, just...
  • Blog Post: Implementing SelectedValue with the Silverlight ComboBox

    Here’s the scenario … You have a Customers collection and an Orders collection. In the Orders collection, an Order has a CustomerID property; this is the key to an item in the Customers collection. Your goal is a ComboBox that updates the CustomerID property of a Customer, but interacts with the end...
  • Blog Post: An ICommand with IsEnabled

    ICommand is a simple interface with three members – Execute, CanExecute, and CanExecuteChanged (more on those here ). You can write your own implementations of that interface, one for each command, but that gets a bit heavyweight. So there are several implementations of ICommand that are pluggable and...
  • Blog Post: A master/detail view with navigation

    I don’t remember what got me thinking about it, but somewhere along the line I wanted a master/detail view with a navigation bar. E.g., when you change selection in the master view, you can navigate back to the previous selection. Here’s an example (here my selection started on “Wilma”, then I...
  • Blog Post: A Comparable DataTrigger

    Property triggers today only check for equality. We’d like to add support for other comparison operators, but that hasn’t happened yet. But I needed them for a project, and wrote a workaround for it. It’s a bit hacky in a couple of places, but if you can get past that, it’s a handy way to simplify some...
  • Blog Post: Binding to anonymous types in an Xbap or Silverlight application

    It's easy to use Linq queries to create objects, and to use {Binding}s to bind properties of those objects into your view. If you're doing this for an application that will run as an Xbap ("WPF Browser Application") or as a Silverlight app, just note that you need to generate nominal types rather than...
  • Blog Post: Simple way to create a gradient brush in Xaml

    Rob , Nikhil & I were talking today about the early days of Xaml when you could create linear gradient brushes as an attribute value. E.g. (borrowing from Rob’s post on this subject) instead of creating a LinearGradientBrush for the fill of a rectangle with this Xaml: < Rectangle Width ="300...
  • Blog Post: A Context-Sensitive Help Provider in Wpf

    Here's an example of a way to add context-sensitive help to your application. The main idea is to simply use the built-in ApplicationCommands.Help command. This command is already tied to the F1 key, and so executes when you hit F1, and tells your command handler what element the user was on when...
  • Blog Post: Building read-only objects in Xaml

    We often use Xaml to instantiate and initialize objects. For example, given “<Foo Bar=’1’/>”, a Xaml loader creates a Foo object, and sets the Bar property to 1. That works when the Bar property is settable, but what can you do if it isn’t? An example of this scenario in .Net today shows...
  • Blog Post: Two ProgressBar Tricks

    Here’s a couple of handy ProgressBar tricks … The first trick is to use a negative Minimum value, so that as soon as a ProgressBar starts, you give the user the visual feel that the progress has already begun. This is especially useful if, in your scenario, it takes a couple of seconds to get the...
  • Blog Post: Expandos in xaml

    This post has a couple of suggestions on ways to accomplish expandos in Xaml. F irst some background … On an HTML page you can define your own new “expando” properties on the fly, such as in this example: < HTML > < BODY onload = ' paragraph1.innerText = paragraph1.testing ' >...
  • Blog Post: How to target a template setter at non-element content

    Here’s a technique you can follow to use property triggers in a template on non-element type objects. First, though, some background on what that means … Take this example of a Button with a custom template which is simply a rectangle: < Button > < Button.Template > <...
  • Blog Post: Tip: Using XamlWriter and XamlReader to clone an object

    There are multiple ways to clone objects, and multiple definitions of what “clone” should even mean. The main issue is usually about cloning “deep” vs. “shallow”. For example, if you have a Customer object that points to an Address object, and you clone the Customer object, does the Address object...
  • Blog Post: Parameterized templates; and how to create reusable, custom-looking buttons without code

    I’ve talked to a few people recently about parameterized templates, and so I wanted to write some of it down. Here’s the scenario … I want to create an application that has a main window with several buttons on it. Clicking one of the buttons navigates you to part of an app. For example, in this picture...
  • Blog Post: How to control the mouse cursor

    How to set the mouse cursor in one easy step: set the Cursor property. For example, this markup: < Button Cursor = " Help " > Help </ Button > … sets the cursor to be the “ Help ” cursor, when the mouse is over the button. Note that since Cursor is scoped, it doesn’t apply...
  • Blog Post: A TreeView, a HierarchicalDataTemplate, and a 2D collection walk into a bar ...

    Bea has a handy post describing how to group items in a collection using a CollectionViewSource. I was looking at that, and a post on the WPF forum from markovuksanovic, and for fun created a version of Bea’s example that uses a 2D collection instead of the CollectionViewSource. (I found a bunch of HierarchicalDataTemplate...
  • Blog Post: Limited generics support in Xaml

    In a post to the WPF forum, Zhou Yong had the idea to use a MarkupExtension to make it possible to create a generic dictionary (Dictionary<K,V>) from Xaml. It’s a cool idea, so I played with it a bit, with the result shown below. The end result is that you can do the following, for example, where...
  • Blog Post: Tip: Cannot animate '...' on an immutable object instance

    For the most part, you can animate any property in a WPF application. For example, the following is a rectangle that animates it’s fill color on mouse enter and leave: < Window x:Class = " Scratch.Window1 " xmlns = " http://schemas.microsoft.com/winfx/2006/xaml/presentation " xmlns:x ...
  • Blog Post: Tips & Tricks: How to undo an implicit style

    You can define a style that gets used by all elements of a type, such as this case (this causes all buttons in the page to have a blue background): < Page xmlns = http://schemas.microsoft.com/winfx/2006/xaml/presentation xmlns:x = " http://schemas.microsoft.com/winfx/2006/xaml " > ...
  • Blog Post: A trigger for the TreeViewItem directly under the mouse

    In a post to the WPF forum , martinabc wanted to define a TreeViewItem style that would trigger off whether or not the mouse was over that item. A trigger on the IsMouseOver property sounds promising, but unfortunately IsMouseOver is true not only for the item under the mouse, but for the ancestors of...
  • Blog Post: Trace sources in WPF

    WPF (Avalon) uses the .Net tracing system to provide some diagnostics about what’s going on inside your WPF application. It’s not at all an exhaustive set of traces, and in fact it’s still pretty rudimentary. But frequently it’s enough to help out when you’re trying to debug...
Page 1 of 1 (21 items)