Version

Exclude Specific Control Properties

You can exclude control properties from getting persisted in the Infragistics Persistence Framework™. This example shows you how to exclude the CheckBox control’s Content property from being persisted.

In XAML:

<CheckBox x:Name="chkOption" Content="Email Receipt">
<ig:PersistenceManager.Settings>
    <ig:PersistenceSettings x:Name="settings" SavePersistenceOptions="AllButIgnored" >
        <ig:PersistenceSettings.IgnorePropertySettings>
            <ig:PropertyNamePersistenceInfo PropertyName="Content" />
        </ig:PersistenceSettings.IgnorePropertySettings>
    </ig:PersistenceSettings>
</ig:PersistenceManager.Settings>
</CheckBox>

Set the PersistenceSettings object’s SavePersistenceOptions property to AllButIgnored.

Use the PropertyNamePersistenceInfo object’s PropertyName property to specify the CheckBox control’s Content property that will be ignored for persistence.

In Visual Basic:

' create a new PersistenceSettings object
Dim settings As New PersistenceSettings()
' set save persistence option - AllButIgnored
settings.SavePersistenceOptions = Persistence.Primitives.PersistenceOption.AllButIgnored
' we will identify the specific property by its name
Dim pnpi As New PropertyNamePersistenceInfo()
pnpi.PropertyName = "Content"
' add the property in the IgnorePropertySettings collection
settings.IgnorePropertySettings.Add(pnpi)
Dim memoryStream As MemoryStream = PersistenceManager.Save(chkOption, settings)

In C#:

// create a new PersistenceSettings object
PersistenceSettings settings = new PersistenceSettings();
// set save persistence option - AllButIgnored
settings.SavePersistenceOptions = Persistence.Primitives.PersistenceOption.AllButIgnored;
// we will identify the specific property by its name
PropertyNamePersistenceInfo pnpi = new PropertyNamePersistenceInfo();
pnpi.PropertyName = "Content";
// add the property in the IgnorePropertySettings collection
settings.IgnorePropertySettings.Add(pnpi);
MemoryStream memoryStream = PersistenceManager.Save(chkOption, settings);

Related Topics