My data columns are dynamic so they change based on the query parameters. The column number and/or column labels can change. They way I implemented this is by using the FieldLayoutInitialized event in the code behind.
From doing some reading the FieldLayoutInitialized event will not fire if the column types and column number is the same. The problem I'm having is this:
If a user picks calendar year for the query date range and enters in say 2011 to 2012 the column labels are' 2011' and '2012' but if they pick fiscal year the column labels change to '2011/2012' and '2012/2013' but this does not get updated in the xamdatagrid because the FieldLayoutInitialized event does not fire because I'm assuming the number and type of columns are the same as the previous field layout.
Is there a way to force the FieldLayoutInitialized event to fire every time so my field labels get updated?
Hi KrisVice,
If you are assigning a new DataSource when the query is changed then what you can do is clear out the FieldLayouts collection before assigning the new DataSource. This way when the new DataSource is assigned it won't find any FieldLayouts that match and it will create a new one triggering that event.
How might I accomplish this? I'm using the MVVM pattern. I can't bind to FieldLayouts property because it's read only. How would I clear the FieldLayouts collection in the view model?