Currently I have in xaml:
<ItemsControl ItemsSource="{Binding Facilities, Mode=OneWay}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Border Style="{StaticResource BorderStyleHeader}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="33" />
<RowDefinition Height="33" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="150" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<TextBlock Text="{Binding Name}" HorizontalAlignment="Center" Grid.Row="0" Grid.Column="1" FontWeight="Bold" />
<TextBlock Text="{Binding Description}" Grid.Row="1" Grid.Column="1" />
<Button Content="Reserveer Nu" Style="{StaticResource ButtonStyle}"
Margin="5" Grid.Row="1" Grid.Column="0"
Command="{Binding Reservation.ItemClicked}"
CommandParameter="{Binding FacilityId}"/>
</Grid>
</Border>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
Now the first thing is that I wish for the button to raise the event in my viewmodel
public RelayCommand ItemClicked
{
get
{
return new RelayCommand(() =>
{
MessageBox.Show("Something is clicked");
});
}
}
but it refuses...
secondly I want to be able to raise the event with a parameter (notice the commandparameter) but I have never used it and thus I dont understand how to use it.
So my questions:
Why isn't my relaycommand being executed?
How do I make use of the command parameter?