Question

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 scenario:

  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's constructor is never called, as a result, the wrong data is displayed
  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

So my question is: why doesn't the IValueConverter load when the XamGrid is deserialized?

Practically speaking, there is no need to serialize the entire XamGrid... but that is an entirely separate issue.

ADDITIONAL CONTEXT

  • Infragistics controls version 12.1.20121.2286

SAMPLE CODE

[A] Column Binding

<ig:TemplateColumn  Key="Severity" HeaderText="Event Severity">
<ig:TemplateColumn.ItemTemplate>
   <DataTemplate x:Name="SeverityColumn">
      <Image HorizontalAlignment="Center" Width="16" Height="16" Source="{Binding Converter={StaticResource SourceToTargetConverter}}" />
   </DataTemplate>
</ig:TemplateColumn.ItemTemplate>
</ig:TemplateColumn>

** 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>

REFERENCES

Was it helpful?

Solution

It appears that the TemplateColumn.ItemTemplate (aka: SeverityColumn) 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 the Watch 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

UPDATE 1

Now that I have a better understanding of the what, I can provide an explanation for the why. The following is taken directly from the Infragistics documentation:

"There are some types of properties that are not saved by the Infragistics Control Persistence Framework. It does not save AttachedProperties, DataTemplates, Paths, ControlTemplates, Styles, and ItemPanelTemplates."

[SOURCE: About Infragistics Control Persistence Framework]

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top