My name is Edward Tanguay. I'm an American software and web developer living and working in Berlin, Germany.
4 hours 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.
5 hours 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.
5 hours ago: We're not suffering from information overload, we're suffering from faulty filtering.
6 hours ago: Classic literature for free as nicely formatted 1-page or 2-page PDF downloads: http://www.planetebook.com/free-ebooks.asp.
6 hours ago: Yes, when you pour coffee, "a lightning storm of neuronal activity occurs almost across the entire brain": http://is.gd/eWO1T @pholdings.
22 hours ago: If you put two spaces after a period or use underlining for emphasis, you were born before 1980.
23 hours ago: Word of the day: infovore, n. an animal with a voracious appetite for information.
yesterday: It's said that on average people use less than 10% of their brain, but I think on average computers use less than 1% of their CPU.
2 days ago: Saturday fun: team drawing on two computers with six-year-old in a shared google doc diagram.
2 days ago: Someday I want to produce a developer podcast called "What's that?" but for now "the developer's life" is a nice genre: http://is.gd/eTURO.
3 days 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.
WPF CODE EXAMPLE created on Saturday, February 06, 2010 permalink
Custom ChooserGroup control which allows user to change selection kind from dropdown to radiobuttons
This is an example of how to make a control that abstracts the dropdown and radiobutton controls away so that you can make a "ChooserGroup" and then render it as a: (1) dropdown, (2) radio buttons vertical, or (3) radio buttons horizontal. This control has a custom OnChoiceItemChanged event which even abstracts the handling of a changed item no matter what type of control has been rendered.
XAML:
<Window x:Class="TestRad2343.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    WindowStartupLocation="CenterScreen"
    Title="Window1" Height="350" Width="300">
    <Window.Resources>
        <Style TargetType="{x:Type GroupBox}" x:Key="GroupBoxMain">
            <Setter Property="Padding" Value="10" />
            <Setter Property="Margin" Value="0 0 0 10" />
            <Setter Property="BorderBrush" Value="#ccc" />
            <Setter Property="BorderThickness" Value="2" />
        </Style>
        <Style TargetType="{x:Type TextBlock}" x:Key="GroupBoxHeaderMain">
            <Setter Property="FontFamily" Value="Lucida Sans" />
            <Setter Property="FontSize" Value="12" />
            <Setter Property="Foreground" Value="#aaa" />
        </Style>

    </Window.Resources>

    <StackPanel Margin="10" HorizontalAlignment="Left">

        <GroupBox Style="{DynamicResource GroupBoxMain}" Margin="0 0 0 10">
            <GroupBox.Header>
                <TextBlock Text="Switch the Chooser"
                                    Style="{DynamicResource GroupBoxHeaderMain}"/>
            </GroupBox.Header>
            <StackPanel>
                <StackPanel HorizontalAlignment="Left" VerticalAlignment="Top" >
                    <Button x:Name="ButtonForDropDown" Content="Drop Down" Padding="3" Margin="0 0 0 3" Click="Button_Click_DropDown"/>
                    <Button x:Name="ButtonForRadioButtonsHorizontal" Content="Radio Buttons Horizontal" Padding="3" Margin="0 0 0 3" Click="Button_Click_RadioButtonsHorizontal" />
                    <Button x:Name="ButtonForRadioButtonsVertical" Content="Radio Buttons Vertical" Padding="3" Margin="0 0 0 3"    Click="Button_Click_RadioButtonsVertical"/>
                </StackPanel>
            </StackPanel>
        </GroupBox>

        <StackPanel HorizontalAlignment="Left" Margin="0 0 0 10">
            <ContentControl x:Name="ControlArea"/>
        </StackPanel>

        <StackPanel HorizontalAlignment="Left" Margin="0 0 0 10">
            <Button x:Name="SubmitButton" Content="Submit" Click="Button_Click_Submit"/>
        </StackPanel>

        <TextBlock x:Name="Message" Foreground="Blue" Margin="0 0 0 10"/>
    </StackPanel>
</Window>

Code Behind:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Globalization;
using System.ComponentModel;

namespace TestRad2343
{
    public partial class Window1 : Window, INotifyPropertyChanged
    {
        #region ViewModelProperty: SelectedIdCode
        private string _selectedIdCode;
        public string SelectedIdCode
        {
            get
            {
                return _selectedIdCode;
            }

            set
            {
                _selectedIdCode = value;
                OnPropertyChanged("SelectedIdCode");
            }
        }
        #endregion //test

        private ChooserDirection chooserDirection = new ChooserDirection();
        private ChooserKind chooserKind = new ChooserKind();

        private string choices = "one, two, three, four, five, six";

        public Window1()
        {
            InitializeComponent();

            chooserKind = ChooserKind.RadioButtons;
            chooserDirection = ChooserDirection.Vertical;
            ManageButtonEnabling("radioButtonsVertical");
            SelectedIdCode = "two";

            RefreshPage();
        }

        void RefreshPage()
        {
            WrapPanel wp = new WrapPanel();
            ChooserGroup chooserGroup = new ChooserGroup("chooser1", choices, SelectedIdCode);
            chooserGroup.ChooserKind = chooserKind;
            chooserGroup.ChooserDirection = chooserDirection;
            ControlArea.Content = chooserGroup.Render();
            chooserGroup.OnChoiceItemChanged += new ChooserGroup.ChoiceItemChangedHandler(chooserGroup_OnChoiceItemChanged);

            SubmitButton.Tag = chooserGroup;
        }

        void chooserGroup_OnChoiceItemChanged(object sender, ChoiceItemArgs args)
        {
            ChooserGroup chooserGroup = sender as ChooserGroup;
            SelectedIdCode = chooserGroup.GetSelectedIdCode();
        }

        private void Button_Click_Submit(object sender, RoutedEventArgs e)
        {
            ChooserGroup chooserGroup = ((Button)sender).Tag as ChooserGroup;
            Message.Text = String.Format("You selected '{0}'.", chooserGroup.GetSelectedIdCode());
        }

        private void Button_Click_DropDown(object sender, RoutedEventArgs e)
        {
            chooserKind = ChooserKind.DropDown;
            ManageButtonEnabling("dropDown");
            RefreshPage();
        }

        private void Button_Click_RadioButtonsHorizontal(object sender, RoutedEventArgs e)
        {
            chooserKind = ChooserKind.RadioButtons;
            chooserDirection = ChooserDirection.Horizontal;
            ManageButtonEnabling("radioButtonsHoriztonal");
            RefreshPage();
        }

        private void Button_Click_RadioButtonsVertical(object sender, RoutedEventArgs e)
        {
            chooserKind = ChooserKind.RadioButtons;
            chooserDirection = ChooserDirection.Vertical;
            ManageButtonEnabling("radioButtonsVertical");
            RefreshPage();
        }

        public void ManageButtonEnabling(string buttonToEnable)
        {
            switch (buttonToEnable)
            {
                case "dropDown":
                    ButtonForDropDown.IsEnabled = false;
                    ButtonForRadioButtonsHorizontal.IsEnabled = true;
                    ButtonForRadioButtonsVertical.IsEnabled = true;
                    break;
                case "radioButtonsHoriztonal":
                    ButtonForDropDown.IsEnabled = true;
                    ButtonForRadioButtonsHorizontal.IsEnabled = false;
                    ButtonForRadioButtonsVertical.IsEnabled = true;
                    break;
                case "radioButtonsVertical":
                    ButtonForDropDown.IsEnabled = true;
                    ButtonForRadioButtonsHorizontal.IsEnabled = true;
                    ButtonForRadioButtonsVertical.IsEnabled = false;
                    break;
                default:
                    break;
            }
        }

        #region INotifiedProperty Block
        public event PropertyChangedEventHandler PropertyChanged;

        protected void OnPropertyChanged(string propertyName)
        {
            PropertyChangedEventHandler handler = PropertyChanged;

            if (handler != null)
            {
                handler(this, new PropertyChangedEventArgs(propertyName));
            }
        }
        #endregion //test

    }

    public class ChooserGroup
    {
        public ChooserDirection ChooserDirection { get; set; }
        public ChooserKind ChooserKind { get; set; }

        private string idCode;
        private List<ChoiceItem> choiceItems = new List<ChoiceItem>();
        private List<RadioButton> internalRadioButtons = new List<RadioButton>();
        private ComboBox internalComboBox = new ComboBox();
        private List<ComboBoxItem> internalComboBoxItems = new List<ComboBoxItem>();


        public delegate void ChoiceItemChangedHandler(object obj, ChoiceItemArgs args);
        public event ChoiceItemChangedHandler OnChoiceItemChanged;


        public ChooserGroup(string chooserIdCode, string choiceList, string selectedChoice)
        {
            idCode = chooserIdCode;
            List<string> choices = choiceList.BreakIntoParts(',');
            choiceItems = ChoiceItem.GetChoiceItemsWithStringList(choices, selectedChoice);
            ChooserKind = ChooserKind.RadioButtons;
            ChooserDirection = ChooserDirection.Vertical;
        }

        public StackPanel Render()
        {
            switch (ChooserKind)
            {
                case ChooserKind.RadioButtons:
                    return RenderAsRadioButtons();
                case ChooserKind.DropDown:
                    return RenderAsDropDown();
                default:
                    return new StackPanel();
            }
        }

        StackPanel RenderAsDropDown()
        {
            StackPanel spWrapper = new StackPanel();
            int index = 0;
            foreach (var choiceItem in choiceItems)
            {
                ComboBoxItem comboBoxItem = new ComboBoxItem { Tag = choiceItem.IdCode, Content = choiceItem.Title };
                internalComboBox.Items.Add(comboBoxItem);
                if (choiceItem.IsSelected)
                    internalComboBox.SelectedIndex = index;
                index++;
                internalComboBoxItems.Add(comboBoxItem);
            }
            if (internalComboBox.SelectedItem == null)
            {
                if (internalComboBox.Items.Count > 0)
                    internalComboBox.SelectedItem = internalComboBox.Items[0];
            }
            spWrapper.Children.Add(internalComboBox);

            internalComboBox.SelectionChanged += new SelectionChangedEventHandler(internalComboBox_SelectionChanged);

            return spWrapper;

        }

        void internalComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            ChoiceItemArgs args = new ChoiceItemArgs("");
            OnChoiceItemChanged(this, args);
        }

        StackPanel RenderAsRadioButtons()
        {
            StackPanel spWrapper = new StackPanel();

            StackPanel spDirectionWrapper = new StackPanel();
            WrapPanel wpDirectionWrapper = new WrapPanel();

            foreach (var choiceItem in choiceItems)
            {
                RadioButton rb = new RadioButton();
                rb.Content = choiceItem.Title;
                rb.Tag = choiceItem.IdCode;
                rb.GroupName = idCode;
                rb.Cursor = Cursors.Hand;
                if (choiceItem.IsSelected)
                    rb.IsChecked = true;
                else
                    rb.IsChecked = false;

                if (ChooserDirection == ChooserDirection.Horizontal)
                {
                    rb.Margin = new Thickness(5);
                    wpDirectionWrapper.Children.Add(rb);
                }
                else
                {
                    spDirectionWrapper.Children.Add(rb);
                }
                rb.Checked += new RoutedEventHandler(rb_Checked);
                internalRadioButtons.Add(rb);
            }

            if (ChooserDirection == ChooserDirection.Horizontal)
                spWrapper.Children.Add(wpDirectionWrapper);
            else
                spWrapper.Children.Add(spDirectionWrapper);

            return spWrapper;
        }

        void rb_Checked(object sender, RoutedEventArgs e)
        {
            ChoiceItemArgs args = new ChoiceItemArgs("");
            OnChoiceItemChanged(this, args);
        }

        public string GetSelectedIdCode()
        {
            switch (ChooserKind)
            {
                case ChooserKind.RadioButtons:
                    return GetSelectedIdCodeFromRadioButtons();
                case ChooserKind.DropDown:
                    return GetSelectedIdCodeFromDropDown();
                default:
                    return "";
            }
        }

        string GetSelectedIdCodeFromRadioButtons()
        {
            foreach (var internalRadioButton in internalRadioButtons)
            {
                if (internalRadioButton.IsChecked.Value)
                    return internalRadioButton.Tag.ToString();
            }
            return null;
        }

        string GetSelectedIdCodeFromDropDown()
        {
            int selectedIndex = internalComboBox.SelectedIndex;
            ComboBoxItem selectedComboBoxItem = internalComboBoxItems[selectedIndex];
            return selectedComboBoxItem.Tag.ToString();
        }
    }

    public class ChoiceItemArgs : EventArgs
    {
        public string Message { get; set; }

        public ChoiceItemArgs(string message)
        {
            Message = message;
        }
    }

    public enum ChooserDirection
    {
        Horizontal,
        Vertical
    }

    public enum ChooserKind
    {
        DropDown,
        RadioButtons
    }

    public class ChoiceItem
    {
        public string IdCode { get; set; }
        public string Title { get; set; }
        public bool IsSelected { get; set; }

        public static List<ChoiceItem> GetChoiceItemsWithStringList(List<string> rawChoices, string selectedValue)
        {
            if (rawChoices == null)
                return null;
            List<ChoiceItem> choiceItems = new List<ChoiceItem>();
            foreach (var rawChoice in rawChoices)
            {
                ChoiceItem ci = new ChoiceItem();
                ci.IdCode = rawChoice;
                TextInfo text = new CultureInfo("en-US", false).TextInfo;
                ci.Title = text.ToTitleCase(rawChoice);
                if (ci.IdCode == selectedValue)
                    ci.IsSelected = true;
                choiceItems.Add(ci);
            }
            return choiceItems;
        }
    }

    public static class StringHelpers
    {
        public static List<string> BreakIntoParts(this string line, char separator)
        {
            if (String.IsNullOrEmpty(line))
                return null;
            else
                return line.Split(separator).Select(p => p.Trim()).ToList();
        }
    }
}
need markup?