i am struggling with binding a Button inside of a UserControl (which is placed inside of a ListBox.ItemTemplate) to my ViewModel.
Page A contains the following Listbox:
<ListBox x:Name="lbUpcomingBetgames" ItemsSource="{Binding UpcomingBetgames}" Background="{x:Null}">
<ListBox.ItemContainerStyle>
<Style TargetType="ListBoxItem">
<Setter Property="HorizontalAlignment" Value="Stretch"/>
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
<Setter Property="Margin" Value="0,4,0,4"/>
</Style>
</ListBox.ItemContainerStyle>
<ListBox.ItemTemplate>
<DataTemplate>
<customControl:BetgameInfoControl x:Name="upcomingBetgameControl" />
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
My ViewModel contains a RelayCommand that i want to bind to in my CustomControl BetgameInfoControl:
public RelayCommand BetgameRegisterClicked
{
get;
private set;
}
My CustomControl contains a Button:
<Button Grid.Row="0" Content="Accept" Height="50" Command="{Binding Path=Parent.DataContext.BetgameRegisterClicked, ElementName=upcomingBetgameControl}" CommandParameter="{Binding Description}" />
The RelayCommand is never called. I tried different ways to bind the Command-Property in my Button but nothing worked.
Can someone help me please?