Welcome to MSDN Blogs Sign in | Join | Help

Data See, Data Do

Mike Hillberg's Blog on Wpf and Silverlight

Syndication

News

All postings are provided "As Is" with no warranties, and confers no rights. Opinions and views expressed here are not necessarily those of Microsoft Corporation.


Browse by Tags

All Tags » Tips and Tricks   (RSS)
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 Read More...

Posted Thursday, March 26, 2009 10:53 PM by MikeHillberg | 8 Comments

Filed under:

Attachment(s): SelectedValue.zip

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 Read More...

Posted Monday, March 23, 2009 10:13 PM by MikeHillberg | 4 Comments

Filed under:

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 Read More...

Posted Friday, January 09, 2009 10:50 AM by MikeHillberg | 3 Comments

Filed under:

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 Read More...

Posted Tuesday, September 30, 2008 12:04 AM by MikeHillberg | 6 Comments

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 Read More...

Posted Monday, May 05, 2008 9:56 AM by MikeHillberg | 3 Comments

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 Read More...

Posted Thursday, April 24, 2008 11:06 PM by MikeHillberg | 1 Comments

Filed under: ,

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 Read More...

Posted Thursday, July 26, 2007 10:56 PM by MikeHillberg | 12 Comments

Filed under:

Attachment(s): ContextSensitiveHelp.zip

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 Read More...

Posted Monday, July 02, 2007 10:32 AM by MikeHillberg | 1 Comments

Filed under: ,

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, Read More...

Posted Thursday, May 17, 2007 3:57 PM by MikeHillberg | 2 Comments

Filed under:

Attachment(s): Loading.jpg

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 Read More...

Posted Monday, May 14, 2007 5:36 PM by MikeHillberg | 1 Comments

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 > Read More...

Posted Monday, May 07, 2007 5:04 PM by MikeHillberg | 2 Comments

Filed under:

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 Read More...

Posted Tuesday, May 01, 2007 1:35 PM by MikeHillberg | 2 Comments

Filed under: ,

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 Read More...

Posted Thursday, February 01, 2007 9:26 AM by MikeHillberg | 1 Comments

Filed under: ,

Attachment(s): pt1.jpg

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 Read More...

Posted Wednesday, November 22, 2006 9:48 AM by MikeHillberg | 1 Comments

Filed under:

A TreeView, a HierarchicalDataTemplate, and a 2D collection walk into a bar ...
An example of a TreeView and HierarchicalDataTemplate being used to display a collection of collections. Read More...

Posted Wednesday, October 11, 2006 8:15 AM by MikeHillberg | 7 Comments

Filed under: ,

Attachment(s): hdt.jpg

More Posts Next page »
Page view tracker