Q:

Enable Button when row selected in DataGrid using Expression Blend?

As titled, I want to enable the a Button (that was disabled) when a row from DataGrid (so an object) is selected.
From what I read, WPF seems to have triggers for check when centain property change it can do centain thing?
But in Silverlight it seems I can only use GoToState instead.  I tried to make two states: Selected and UnSelected.  But the IsEnabled property for the Button it doesn't seems being record from UnSelected state to Selected state...
And another problem is the only event that fits from DataGrid is SelectionChanged, but how do I ensure that the User does selected a Row?
If I do everything in code-behide I can check SelectionChangedEvent and enable the buttons, but is there anyway to do everything above with Expression Blend?  I am trying to put everything in xaml as much as possible.
Thanks

A:

Have you tried using ordinary Element binding? For example:
<DataGrid x:Name="MyGrid" />
<Button IsEnabled="{Binding Path=SelectedItem, ElementName=MyGrid, Converter={StaticResource MyNullToBoolConverter}}" />

and an example of the converter:
class MyNullToBoolConverter : IValueConverter
{
    public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
    {
        return value != null ? true : false;
    }

    public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
    {
        throw new NotImplementedException();
    }
}

All you have to do then is declare the converter in the static resources of either the page or the Button.

