My name is Edward Tanguay. I'm an American software and web developer living and working in Berlin, Germany.


9 hours ago: Here's a use-case for datapod format, recording human-readable data that later can be used as a datasource: http://is.gd/eSsLg @pholdings.
9 hours ago: "Subscriptions are available to U.S. addresses only." http://www.highlights.com another global economy #fail.
9 hours ago: "Subscriptions are available to U.S. addresses only." http://www.highlights.com another global #fail.
11 hours ago: My notes on podcast with author Aimee Bender's Lemoncake book, "a normal kid punished by expectations of giftedness": http://is.gd/eSsLg.
12 hours ago: Interesting: "one page per book": http://openlibrary.org/about.
12 hours ago: Another after-work 8K, did 5K in 23:33, getting cooler here as #berlin #marathon approaches: http://is.gd/eSp95.
yesterday: C# CODE EXAMPLE: Extension method for checking regex in one line: http://is.gd/eQzyg.
yesterday: New podcast source: "I don't want to put you to sleep, but I want to be as rich, and rewarding, and resident as a dream.":http://is.gd/eQrdC.
yesterday: An intense colin marshall interview with michael silverblatt on the art of interviewing & more: http://is.gd/eQqve (search for "blatt").
yesterday: The stackexchange site for wordpress is up: get your answers / establish your reputation @cottonr http://wordpress.stackexchange.com.
2 days ago: "I've always felt that any time you can use a tuple, you should use a struct.": http://is.gd/eQm9V.
How to create your own commands and bind them in WPF This example shows how to create commands and bind them. You could see this as analogous to how this was done in WinForms, but actually it is looser than that, since you could use e.g. a test class to call the same commands to test that they are working correctly. XAML:
<Window x:Class="TestCommands.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:TestCommands" Title="Window1" Height="300" Width="300"> <Window.CommandBindings> <CommandBinding Command="{x:Static local:Window1.CommandOne}" Executed="CommandBinding_Executed"/> <CommandBinding Command="{x:Static local:Window1.CommandTwo}" Executed="CommandBinding_Executed"/> <CommandBinding Command="{x:Static local:Window1.CommandThree}" Executed="CommandBinding_Executed"/> </Window.CommandBindings> <Grid> <StackPanel Margin="10"> <TextBlock x:Name="TheTextBlock" Text="make a choice below"/> <RadioButton GroupName="radioColor" IsChecked="True" Content="Blue" Command="{x:Static local:Window1.CommandOne}"/> <RadioButton GroupName="radioColor" IsChecked="False" Content="Red" Command="{x:Static local:Window1.CommandTwo}"/> <RadioButton GroupName="radioColor" IsChecked="False" Content="Green" Command="{x:Static local:Window1.CommandThree}"/> <Button Content="Change text to Red" Command="{x:Static local:Window1.CommandTwo}"/> </StackPanel> </Grid> </Window> code behind:
using System.Windows;
using System.Windows.Input; using System.Windows.Media; namespace TestCommands { public partial class Window1 : Window { public static readonly RoutedCommand CommandOne = new RoutedCommand(); public static readonly RoutedCommand CommandTwo = new RoutedCommand(); public static readonly RoutedCommand CommandThree = new RoutedCommand(); public Window1() { InitializeComponent(); } private void CommandBinding_Executed(object sender, ExecutedRoutedEventArgs e) { if (e.Command == CommandOne) { TheTextBlock.Foreground = new SolidColorBrush(Colors.Blue); } else if (e.Command == CommandTwo) { TheTextBlock.Foreground = new SolidColorBrush(Colors.Red); } else if (e.Command == CommandThree) { TheTextBlock.Foreground = new SolidColorBrush(Colors.Green); } } } } |
Most Recently Added Items:
- Extension method for checking regex in one line - c# code example - added yesterday
- How to use a Dictionary<> with struct key to save a dynamic matrix of objects - c# code example - added on Sunday, August 22, 2010
- A simple jquery search machine for a web page - jquery code example - added on Sunday, August 22, 2010
- Wrapper class to simplify the creation of Excel files in C# 4.0 - wpf code example - added on Tuesday, July 20, 2010
- How to make clickable flashcards in plain javascript for your mobile phone - javascript code example - added on Wednesday, July 07, 2010
- Simple example of javascript which loads jquery locally - jquery code example - added on Wednesday, July 07, 2010
- How to stop regular expression greediness - c# code example - added on Tuesday, July 06, 2010
- How to use a generic dictionary to total enum values - c# code example - added on Friday, July 02, 2010
- Generic method to case-insensitively convert a string to any enum - c# code example - added on Friday, July 02, 2010
- How to create a TextBlock that has various font formatting in code behind - silverlight code example - added on Wednesday, June 30, 2010
- How to encode binary files to text files and back to binary again - c# code example - added on Wednesday, June 30, 2010
- How to use a custom parameter struct to pass any number of variables to constructors of similar classes. - c# code example - added on Saturday, June 26, 2010
- How to make a class that renders an interactive FrameworkElement and interacts with the View - silverlight code example - added on Tuesday, June 15, 2010
- How to set a nullable type to null in a ternary operator - c# code example - added on Tuesday, June 15, 2010
- How to override events in inherited classes - c# code example - added on Friday, June 11, 2010
- How to strip off e.g. "note:" and "firstName: " from the left of a string using regex - c# code example - added on Tuesday, June 01, 2010
- How to create and subscribe to custom events using EventHandler - c# code example - added on Wednesday, May 12, 2010
- Code base for asynchronously loading and caching dependent data in a Silverlight app - silverlight code example - added on Wednesday, May 05, 2010
- Function to trim the preceding and trailing blank lines off an array - php code example - added on Sunday, May 02, 2010
- How to load and display the contents of a text file with AJAX/Jquery - jquery code example - added on Sunday, May 02, 2010
- How to use fopen() to create a proxy site to read any website content into AJAX - php code example - added on Sunday, May 02, 2010
- Code base for loading and caching external data into a silverlight app - silverlight code example - added on Friday, April 30, 2010
- An UpdateSourceTrigger workaround for Silverlight - wpf code example - added on Sunday, April 18, 2010
- Silverlight layout with click-in info panel - silverlight code example - added on Thursday, April 01, 2010
- How to get querystring variables and change HTML elements from Silverlight. - silverlight code example - added on Thursday, April 01, 2010
- XAML and code for a basic chat window in WPF - wpf code example - added on Saturday, March 27, 2010
- How to consume text from any Google Document, RSS feed, or Twitter feed in your Silverlight application - wpf code example - added on Sunday, March 21, 2010
- How to overlay one image on top of another in code behind - wpf code example - added on Saturday, March 20, 2010
- How to get the mouse-click and mouseover coordinates from an image - wpf code example - added on Tuesday, March 16, 2010
- How to use OrderedDictionary to lookup items by string key or integer index - c# code example - added on Tuesday, March 16, 2010