Use DynamicResource because the resource is defined in an external file and will not be resolved until runtime.
Z
zameb
@zameb
Posts
-
WPF Weird behavior or me? [modified] -
Export WPF ListView data to excelThe ListView in WPF is so different to the Forms one. :~ Maybe the problem is how to iterate inside the ListView items. Here it is:
GridView grid = source.View as GridView; if (grid == null) { //Sorry, only for GridView views return; } foreach (GridViewColumn col in grid.Columns) { //value of header is col.Header } foreach (Object item in source.Items) { PropertyInfo\[\] dataFields = item.GetType().GetProperties(); int i = 0; foreach (GridViewColumn col in grid.Columns) { try { //Get the name of field displayed on grid string strPath = ((Binding)col.DisplayMemberBinding).Path.Path; //Get the field value object propValue = GetValue(item, source.Items, strPath); //Value of cell is propValue } catch (Exception) { } } }
I think it will be easier to export (to excel, pdf or anything) from here.