I'm trying to automatically generate a button list from a XML file.
Here is my XML:
<WPFDS>
    <Title>Hospital</Title>
    <BUTTONS>
        <BUTTON id="1" visible="1">
              <Text>Content1</Text>
              <Program>b1_Click<Program>
        </BUTTON>
        <!-- ... -->
    </BUTTONS>
</WPFDS>
The code to make WPF automatically generate the "button list":
<XmlDataProvider x:Key="wpfds"            
                   Source="Config/Config.xml"           
                   XPath="/WPFDS"           
                   IsAsynchronous="False"           
                   IsInitialLoadEnabled="True"  
/>
<!-- ... -->
<ListBox x:Name="lbBotones" 
         ItemsSource="{Binding Source={StaticResource wpfds}, XPath=./BUTTONS/BUTTON}" 
         Margin="0,19,0,354" Grid.Row="1" IsEnabled="True" Width="607"                     
         HorizontalContentAlignment="Stretch" BorderBrush="{x:Null}" 
         Background="{x:Null}" 
         ScrollViewer.HorizontalScrollBarVisibility="Disabled"
         ScrollViewer.VerticalScrollBarVisibility="Disabled" Height="346"
>
    <ListBox.ItemsPanel>
        <ItemsPanelTemplate>
            <WrapPanel IsItemsHost="True" Orientation="Horizontal"/>
        </ItemsPanelTemplate>
    </ListBox.ItemsPanel>
    <ListBox.ItemTemplate>                    
        <DataTemplate>                        
            <Button Height="50" Width="150" Margin="70,10"
                    Content="{Binding XPath=./Text}"                                    
            />                        
        </DataTemplate>
    </ListBox.ItemTemplate>
</ListBox>
With this, the list of buttons is generated correctly, but the problem is that I also need to "automatically" assign a Click Event to each Button. Is it possible to specify the click event from the XML document? Something like:
Click="{Binding XPath=./Program}"
But it doesn't work.
Thanks for your help!