i have a View (view1) inside another View (viewContainer).
if in view1, i have <igDP:Field Name="field1" label="field1" />
and I am trying to set the width of this field programmatically.
by doing this in the view's code behind:
DataPresenter1.FieldLayouts[0].Fields["field1"].Settings.CellWidth = 50. The reason i have to do this is I need to save the width of the fields when the datapresenter was last closed and load it back up with those same fields, so 50 is just an arbitrary number I am testing with.
however, when I do this, my instance of view1 inside viewContainer no longer loads and says "Cound not create an instance of type 'view1'.
I have also tried putting the width inside the ViewModel and binding it that way... but that did not work either.
Any suggestions?
Thanks alex!
There a couple of thing to consider in this scenario.
1. If you need to save the XamDataGrid's state and restore it, please note that there is a built-in functionality for this - SaveCustomizations and LoadCustomizations. You can find more information here :
http://community.infragistics.com/wpf/codesamples/save-and-load-customizations-in-the-xamdatagrid.aspx
2. The event you are trying to set the width. As you are accessing collections of fieldlayouts and fields, you have to make sure that both the fields and the fieldlayout are already generated. What event are you trying to do this?
3. You probably want to make sure that you set both the CellWidth and LabelWidth properties.
Try 1) and let me know if that is what you are trying to achieve?