Hi,
My problem is a little complex, but I have no idea how to solve it, so i try to ask you about this.
In WPF, my datagird column header is sortable. So, when i click once, the arrow appears and datagrid is sorted desc, then asc etc..
I need to have a sorted (with arrow visible) datagrid at start of my window. So I add SortDirection="Descending" to my DataGridTextColumn. Like this:
<DataGridTextColumn Binding="{Binding Path=SysTask}" Header="SysTask" Width="80" MinWidth="60" SortDirection="Descending"/>
Now, when I open my window, datagrid is sorted, the arrow is visible. But.. it's not ok. It is NOT THE SAME, as open the window without arrow, not sorted datagrid, and then click the header to sort. It's not the same, and i'm looking for the event - "click on the datagrid column header to sort".
I need, to click on column header programmatically from code. Is that possible?
I tell you why, it's not the same and why I need that event:
I have datagrid, which has to be sorted every couple of seconds. Datagrid could be big, so I do it like that: get new list, check if there are changes and then remove or add new records. Very simple..
But, when I do "SortDirection="Descending"", open window with already sorted datagrid with arrow etc... and when I add new record, it still appears on the end of the datagrid! Then when I click on header - it's moved for the right position. I have to click only once on column header, and when method add sth to list, it's on the right place. So I have to click on this header programmatically.
A second reason, I have a problem with refreshing.
When I call my refresh method from timer: fail. When I call it from button click: it works. When refresh method is called by timer, it fails, but when I click sort desc, click sort asc on header - it works. So I need that "click column header" event for that to.