views:

36

answers:

1

I have created a style for a listbox item which shows up the button. I can't fire the click event of a button as the style is kept in resources.xaml. How to fire the click event of a button?

I am setting the command property of a button :

<Button x:Name="image"  Grid.Column="9" Margin="4 0 4 0" Style="{StaticResource LedgerDeleteIcon}" HorizontalAlignment="Right"
                  Command="{Binding DeleteCommand}" CommandParameter="{Binding}" />

and in the usercontrol where i applying this style to a listbox, i am defining a delegate command :

public DelegateCommand DeleteCommand{ get; private set; }

and in constructor of the user control:

   this.DeleteCommand = new DelegateCommand(click_DeleteBn);


private void click_DeleteBn(object args)
{

}

But it doesn't fire am i doing anytinh wrong ?

+2  A: 

Using Silverlight 4 the best way to do this is to bind the Button Command property to an implementation of ICommand.

AnthonyWJones