I'm using Wpf and I'm passing a List<Value> to a <ItemsControl> in the xaml. I would like to bind the string in the Value Object to the Command of a Button. This xaml part looks like this:
<Grid Margin="0,0,2,0"> <Grid Margin="10"> <ItemsControl Name="details"> <ItemsControl.ItemTemplate> <DataTemplate> <Grid Margin="0,0,0,5"> <Grid.ColumnDefinitions> .... </Grid.ColumnDefinitions> ... <Button Grid.Column="2" Content="{Binding ButtonContent}" Visibility="{Binding ButtonVisibility}" Command="{Binding ButtonClickMethod}" /> ... My Value Class looks like this:
public class Value { ... public string ButtonClickMethod { get; set; } } I'm setting the string link this:
v.ButtonClickMethod = "RelatedActivityId_OnClick"; And the Method is in the same class and looks like this:
private void RelatedActivityId_OnClick(object sender, RoutedEventArgs e) { MessageBox.Show("RelatedActivityId_OnClick"); } Everything besides this is working properly and unses the same Object for the binding. What am I doing wrong?
ButtonClickMethodcontains the name of the method to execute?