Some of the FAQs about data binding are:

• How do I bind to a method?
• How do I bind between instantiated controls?
• How do I bind an ItemsControl to an enum?

I put together a quick sample that should answer the above questions:






  Title="Show Enums in a ListBox using Binding">



    <ObjectDataProvider MethodName="GetValues"

                        ObjectType="{x:Type sys:Enum}"



        <x:Type TypeName="HorizontalAlignment" />





  <Border Margin="10" BorderBrush="Aqua"

          BorderThickness="3" Padding="8">

    <StackPanel Width="300">

      <TextBlock>Choose the HorizontalAlignment

                 value of the Button:</TextBlock>

      <ListBox Name="myComboBox" SelectedIndex="0" Margin="8"

               ItemsSource="{Binding Source={StaticResource


      <Button Content="Click Me!"

              HorizontalAlignment="{Binding ElementName=myComboBox,





The ListBox and the Button are hooked up such that you can “control” the HorizontalAlignment value of the Button by selecting a value in the ListBox. This is a screenshot of the example:

So, the answers to the questions are:

• You bind to a method using the ObjectDataProvider. In the example above, we are binding to Enum.GetValues. Specifically, Enum.GetValues(typeof(HorizontalAlignment)).
• You bind the property of a control to a property of another control using the ElementName property of the Binding class. In the example above, the Button HorizontalAlignment property is bound to the SelectedItem property of the ComboBox.
• You bind to an enum by binding to the Enum.GetValues method.