Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
225
IValueConverter does not fire when XamGrid is deserialized
posted

Dear community,

While I have worked with C# for a number of years now, I must admit that I am new to WPF + Infragistics controls.  If you have any insight, I would love to hear your thoughts on the following:

  1. The PersistenceManager is configured for the XamGrid using XAML. (see: [B] Persist Everything)
  2. application starts (for the first time)
  3. XamGrid is bound to a datasource
  4. binding includes a converter (see: [A] Column Binding )
  5. the converter works as expected
  6. user adjusts the size of the `Id` column
  7. data is serialized via: PersistenceManager.Save(IgPersistenceGroup);
  8. application closed
  9. application started (for the second time)
  10. XamGrid is derserialized via: PersistenceManager.Load(IgPersistenceGroup, _persistedData.IgPersistenceMemoryStream);
  11. XamGrid is bound to the data source
  12. new data is displayed as expected
  13. the converter is never called
  14. the `Id` column is the expected size

In this particular case, the XamGrid's entire object tree is being serialized/deserialized.  As a result, I suspect that my problem is related to:

  1. the bindings being serialized/deserialized, or
  2. the converter is being referenced as a StaticResource and that that reference no longer makes sense when the application starts for a second time
Practically speaking, there is no need to persist the entire XamGrid object tree.  So... I implemented [C] Persist Customized Values.  Even though the PersistenceManager is able to Save/Load the XamGrid without issue (no binding errors, no exceptions, etc.) , this scenario does not work - the `Id` column size will always revert back to it's original width when the application is launched (as defined in XAML).  
Thoughts?

ADDITIONAL CONTEXT

  • Infragistics controls version 12.1.20121.2286

SAMPLE CODE

[A] Column Binding

<ig:TemplateColumn.ItemTemplate>
   <DataTemplate>
      <Image HorizontalAlignment="Center" Width="16" Height="16" Source="{Binding Converter={StaticResource SourceToTargetConverter}}" />
   </DataTemplate>
</ig:TemplateColumn.ItemTemplate>

** SourceToTargetConverter: is not the converter's real name - the converter's name is irrelevant here

[B] Persist Everything

<ig:XamGrid ig:PersistenceManager.PersistenceGroup="{DynamicResource igPG}" 

<ig:PersistenceManager.Settings>
   <ig:PersistenceSettings SavePersistenceOptions="AllButIgnored" >
      <ig:PersistenceSettings.PropertySettings>
         <ig:PropertyNamePersistenceInfo PropertyName="FilteringSettings"/>
      </ig:PersistenceSettings.PropertySettings>
   </ig:PersistenceSettings>
</ig:PersistenceManager.Settings>

[C] Persist Customized Values

<ig:XamGrid ig:PersistenceManager.PersistenceGroup="{DynamicResource igPG}" 

<ig:PersistenceManager.Settings>
   <ig:PersistenceSettings SavePersistenceOptions="OnlySpecified" LoadPersistenceOptions="OnlySpecified">
      <ig:PersistenceSettings.PropertySettings>
         <ig:PropertyNamePersistenceInfo PropertyName="ColumnResizingSettings"/>
         <ig:PropertyNamePersistenceInfo PropertyName="ColumnMovingSettings"/>
         <ig:PropertyNamePersistenceInfo PropertyName="SortingSettings"/>
         <ig:PropertyNamePersistenceInfo PropertyName="ColumnChooserSettings"/>
         <ig:PropertyNamePersistenceInfo PropertyName="GroupBySettings" Options="Contains"/>
      </ig:PersistenceSettings.PropertySettings>
   </ig:PersistenceSettings>
</ig:PersistenceManager.Settings>

Sample code is from: XamGrid Persistence Settings
http://es.infragistics.com/community/forums/t/63366.aspx?PageIndex=1

Parents
  • 225
    Verified Answer
    posted

    It appears that the TemplateColumn.ItemTemplate is not being serialized when the XamGrid is persisted using the ig:PersistenceManager. As a result:

    1. When the application starts for the first time, the TemplateColumn.ItemTemplate is loaded from BAML and the column is displayed with the appropriate formatting (using the supplied IValueConverter).
      • NOTE: you will be able to see the ItemTemplate using Visual Studio's debugger and theWatch window
    2. In the current configuration, the ig:PersistenceManager is explicitly setting the TemplateColumn.ItemTemplate to null when the XamGrid is being deserialized.
      • the reason why unformatted data is being displayed in the column is because the XamGrid is automatically falling back to the ig:TemplateColumn's Key to load data from the DataContext
Reply Children
No Data