change image source on row clicked

Apr 9, 2009 at 1:52 AM
Edited Apr 9, 2009 at 12:32 PM
I have a datagrid with a DataGridTemplateColumn. The DataTemplate is a Image wrapped by a Button.

<wpftoolkit:DataGridTemplateColumn Header="Search Type" IsReadOnly="True" >
  <wpftoolkit:DataGridTemplateColumn.CellTemplate>
    <DataTemplate>
      <Button x:Name="btn" Width="25" Height="25" >
        <Image x:Name="icoDisplay" Source="../Resources/plus.png"></Image>
      </Button>
    </DataTemplate>
  </wpftoolkit:DataGridTemplateColumn.CellTemplate>
</wpftoolkit:DataGridTemplateColumn>

I'm trying to change the image source when a row is selected. I want to show an image with a "+" when the details for a row are not showing. I want to show an image with a "-" when the details for a row are showing. I want to change the image source when the row is selected in any cell of the row, not just when the button/image are selected. I don't have to have the button there if it can be done without it. Any help with this would be greatly appreciated.
Coordinator
Apr 9, 2009 at 1:52 PM
You can track both of these (row selection and details visibility) with your ViewModel.  So for example:

class ViewModel : INotifyPropertyChanged
{
    public bool IsSelected { ... }
    public bool IsRowDetailsVisible { ... }
}

and you setup the bindings to the DataGridRow.  Then on any changes to those properties, set any other properties accordingly (such as properties that represet showing the '+' or '-').