Click here to Skip to main content
15,906,628 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
QuestionWorking with WPF Pin
Member 82251801-Aug-12 9:37
Member 82251801-Aug-12 9:37 
AnswerRe: Working with WPF Pin
Ed Hill _5_1-Aug-12 22:12
Ed Hill _5_1-Aug-12 22:12 
GeneralRe: Working with WPF Pin
Member 82251802-Aug-12 11:00
Member 82251802-Aug-12 11:00 
GeneralRe: Working with WPF Pin
Ed Hill _5_2-Aug-12 22:49
Ed Hill _5_2-Aug-12 22:49 
GeneralRe: Working with WPF Pin
Member 82251806-Aug-12 9:06
Member 82251806-Aug-12 9:06 
GeneralRe: Working with WPF Pin
Ed Hill _5_6-Aug-12 23:25
Ed Hill _5_6-Aug-12 23:25 
GeneralRe: Working with WPF Pin
Member 82251808-Aug-12 4:28
Member 82251808-Aug-12 4:28 
GeneralRe: Working with WPF Pin
Member 822518015-Aug-12 10:59
Member 822518015-Aug-12 10:59 
Ed,

Would you be able to provide some guidance to this problem:

I have a DataGrid which is bound to a DataTable.

Relevant XAML & code ('<' intentionally left off at start of each line):

DataGrid Name="dataGrid1" IsReadOnly="True" ItemsSource="{Binding}"
DataGrid.Columns>
DataGridTextColumn Header="Name" Binding="{Binding Path=Name}" />
DataGridTextColumn Header="Path" Binding="{Binding Path=Path}" />
/DataGrid.Columns>

dataGrid1.DataContext = gridData.dt; // this is a DataTable with 3 columns.

The 3rd dt column is not shown on the grid.

The data table is sorted on the first column and contents are displayed.
The user can sort on either of Name or Path columns/headings by clicking on them.

My question, what is the best approach to update the grid data upon a user sorting on one of the columns? (This requires sorting the DataTable once again on the proper column)

This is what I have observed:

1. Adding a Click event handler on DataGridColumnHeader does fire the event.
I have observed that the value of columnHeader.SortDirection (in sender) is the
CURRENT value, not the target value. Is it correct to say that a given column
sort order goes through these phases:
null --> ascending
descending --> ascending
ascending to descending

I.E. By knowing the current state, the next state is determinable.

2. I can place a trigger in the DataGridColumnHeader's SortDirection property looking for Ascendiing/Descending/null but then what? Can I execute code against this?
If so, can you show me a code fragment.


Your thought on the above 2 approaches.
Furthermore, what is the proper way of solving this issue in your opinion?


Thank-you.
GeneralRe: Working with WPF Pin
Ed Hill _5_15-Aug-12 22:10
Ed Hill _5_15-Aug-12 22:10 
GeneralRe: Working with WPF Pin
Ed Hill _5_16-Aug-12 0:08
Ed Hill _5_16-Aug-12 0:08 
GeneralRe: Working with WPF Pin
Member 822518016-Aug-12 2:09
Member 822518016-Aug-12 2:09 
QuestionDynamic properties from Com Interop Pin
Bob Jiang30-Jul-12 5:04
Bob Jiang30-Jul-12 5:04 
AnswerRe: Dynamic properties from Com Interop Pin
Abhinav S30-Jul-12 6:19
Abhinav S30-Jul-12 6:19 
AnswerRe: Dynamic properties from Com Interop Pin
Pete O'Hanlon31-Jul-12 5:08
mvePete O'Hanlon31-Jul-12 5:08 
GeneralRe: Dynamic properties from Com Interop Pin
Bob Jiang31-Jul-12 5:29
Bob Jiang31-Jul-12 5:29 
GeneralRe: Dynamic properties from Com Interop Pin
Pete O'Hanlon31-Jul-12 5:32
mvePete O'Hanlon31-Jul-12 5:32 
QuestionRijndaelManaged Padding is invalid and cannot be removed Pin
Member 906777730-Jul-12 3:28
Member 906777730-Jul-12 3:28 
AnswerRe: RijndaelManaged Padding is invalid and cannot be removed Pin
Dave Kreskowiak31-Jul-12 4:35
mveDave Kreskowiak31-Jul-12 4:35 
GeneralRe: RijndaelManaged Padding is invalid and cannot be removed Pin
Member 90677771-Aug-12 0:02
Member 90677771-Aug-12 0:02 
GeneralRe: RijndaelManaged Padding is invalid and cannot be removed Pin
Pete O'Hanlon1-Aug-12 2:18
mvePete O'Hanlon1-Aug-12 2:18 
GeneralRe: RijndaelManaged Padding is invalid and cannot be removed Pin
Member 90677771-Aug-12 3:53
Member 90677771-Aug-12 3:53 
GeneralRe: RijndaelManaged Padding is invalid and cannot be removed Pin
Pete O'Hanlon1-Aug-12 4:46
mvePete O'Hanlon1-Aug-12 4:46 
GeneralRe: RijndaelManaged Padding is invalid and cannot be removed Pin
Member 90677771-Aug-12 5:40
Member 90677771-Aug-12 5:40 
GeneralRe: RijndaelManaged Padding is invalid and cannot be removed Pin
Dave Kreskowiak1-Aug-12 4:45
mveDave Kreskowiak1-Aug-12 4:45 
GeneralRe: RijndaelManaged Padding is invalid and cannot be removed Pin
Member 90677771-Aug-12 5:36
Member 90677771-Aug-12 5:36 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.