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


yesterday: Inspiring ted talk: Sugata Mitra: The child-driven education: "any teacher who can be replaced by a machine, should be": http://is.gd/eZRvi.
yesterday: Always so painful to look up the German article of a borrowed IT word: der Framework or das Framework? LEO won't tell me: http://is.gd/eZMeU.
yesterday: I know what podcast I'm listening to tomorrow on my way to work: John Resig on technometria: http://is.gd/eZJfq.
yesterday: C# CODE EXAMPLE: Extension method to sort a generic collection of objects: http://is.gd/eZG6n.
yesterday: C# CODE EXAMPLE: A simple class that represents a matching quiz item: http://is.gd/eZFZV.
yesterday: After-work 13K, two 5Ks under sub-four marathon pace: 23:27, 27:27, legs feel great: http://tanguay.info/run.
2 days ago: 6 yr old daughter's last 2 questions before falling asleep tonight: 1) Why are there humans? 2) Is there anything that doesn't have a name?
3 days ago: If you are a developer in Berlin and need to improve your English, I'm looking for groups to teach after work: http://tanguay.info/itenglish.
3 days ago: As far as I'm concerned, the singularity is already here, every time I wake up twitter tells me something amazing was created while I slept.
3 days ago: We're not suffering from information overload, we're suffering from faulty filtering.
3 days ago: Classic literature for free as nicely formatted 1-page or 2-page PDF downloads: http://www.planetebook.com/free-ebooks.asp.
Two ways to set focus in a programmatically created textbox This example shows you two ways to set focus for a programmatically created TextBox. If you need to set focus WHILE you are adding the TextBoxes for some reason, use the hack (thanks to Adam Nelson), otherwise, if you can, wait till AFTER you have set the ContentControl and then set focus via the parent of the TextBoxes. ![]() XAML:
<Window x:Class="TestFocksdfj.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Window1" Height="300" Width="300"> <StackPanel HorizontalAlignment="Left" Margin="10"> <ContentControl x:Name="FormArea"/> </StackPanel> </Window> Code Behind:
using System.Windows;
using System.Windows.Controls; using System.Threading; using System; using System.Windows.Input; namespace TestFocksdfj { public partial class Window1 : Window { public Window1() { InitializeComponent(); StackPanel sp = new StackPanel(); for (int i = 0; i < 3; i++) { TextBox tb = new TextBox(); tb.Width = 200; tb.Margin = new Thickness { Bottom = 3 }; if (i == 2) { //FocusHelper.Focus(tb); //SOLUTION 1 with hack } sp.Children.Add(tb); } FormArea.Content = sp; //SOLUTION 2 without hack: sp.Children[1].Focus(); } } //hack: static class FocusHelper { private delegate void MethodInvoker(); public static void Focus(UIElement element) { ThreadPool.QueueUserWorkItem(delegate(Object foo) { UIElement elem = (UIElement)foo; elem.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, (MethodInvoker)delegate() { elem.Focus(); Keyboard.Focus(elem); }); }, element); } } } |
Most Recently Added Items:
- Extension method to sort a generic collection of objects - c# code example - added yesterday
- A simple class that represents a matching quiz item - c# code example - added yesterday
- Extension method for checking regex in one line - c# code example - added on Thursday, September 02, 2010
- 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
