Wednesday, January 21, 2015

WPF MVVM DataGridView column header click event command binding

I was doing WPF project with MVVM design pattern. There I used a DataGridView to show my data as a table. But I needed to sort the data in the grid, with my own algorithm instead of using the default sorting. Therefore I needed to bind a command to the header. I did not know any anwer to do that. While searching on the internet I found this answer.

I just had to add these line inside the style of DataGrid Header.

1
2
3
4
5
6
7
<style targettype="{x:Type DataGridColumnHeader}">
    <setter Property="Command"
                            Value="{Binding MyCommand}"/>
    <setter Property="CommandParameter"
                            Value="{Binding Path=Content, RelativeSource={RelativeSource Self}}"/>
              ...
</style>

Salesforce Metadata Deployment

Salesforce Metadata Deployment What are metadata? Let's understand this through a simple example. Imagine you are a Salesforce Admin an...