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
85
xamGrid Persistence Error "PersistenceGroup elements don't match elements in stream"
posted

I tried to save and load user settings to xamgrid using persistence framework 11.2

XAML:

<ig:XamGrid AutoGenerateColumns="False" ColumnLayoutHeaderVisibility="Never" Cursor="Hand" Height="680"   Name="dgQResult"  
                    ItemsSource="{Binding  Path=SchedulingQueueResult}"  Margin="8,7,15,8" Width="Auto"    h:HelpProvider.ScreenName="Scheduling Queue" h:HelpProvider.ControlName="dgQResult" Loaded="dgQResult_Loaded" MouseDoubleClick="dgQResult_MouseDoubleClick">
                        <ig:XamGrid.FilteringSettings>
                            <ig:FilteringSettings AllowFiltering="FilterMenu" />
                        </ig:XamGrid.FilteringSettings>
                        <ig:XamGrid.SelectionSettings>
                            <ig:SelectionSettings CellClickAction="SelectRow" RowSelection="Single" />
                        </ig:XamGrid.SelectionSettings>
                        <i:Interaction.Triggers>
                            <i:EventTrigger EventName="MouseDoubleClick" >
                                <cmd:EventToCommand PassEventArgsToCommand="True" Command="{Binding Path=ViewOrderCommand}" />
                            </i:EventTrigger>
                    </i:Interaction.Triggers>
                        <ig:ContextMenuService.Manager>
                            <ig:ContextMenuManager OpenMode="RightClick">
                                <ig:ContextMenuManager.ContextMenu >
                                    <ig:XamContextMenu Name="XamSchedulingQMenu" Opening="XamSchedulingQMenu_Opening">

                                        <ig:XamMenuItem Header="View All Enrollment Information" >
                                            <ig:XamMenuItem.InputBindings>
                                                <MouseBinding MouseAction="LeftClick"  Command="{Binding Path=LoadOtherScreenCommand}" CommandParameter="PatientEnrollment" />
                                            </ig:XamMenuItem.InputBindings>
                                        </ig:XamMenuItem>

</ig:XamContextMenu>
                                </ig:ContextMenuManager.ContextMenu>
                            </ig:ContextMenuManager>
                        </ig:ContextMenuService.Manager>
                        <ig:XamGrid.Columns>
                            <ig:TextColumn Key="OrderIDKey" HeaderText="OrderIDKey"  Visibility="Collapsed" Width="Auto"  IsFilterable="True"  IsFixable="True" IsGroupable="True"  IsMovable="True" IsResizable="True" IsSortable="True" IsSummable="True" VerticalContentAlignment="Center" IsReadOnly="True" />
                           

... Other Columns ...

<ig:ColumnLayout  Key="Children">
                                <ig:ColumnLayout.Columns>
                                    <ig:TextColumn Key="OrderIDKey" HeaderText="OrderIDKey"  Visibility="Collapsed" Width="Auto"  IsFilterable="True"  IsFixable="True" IsGroupable="True"  IsMovable="True" IsResizable="True" IsSortable="True" IsSummable="True" VerticalContentAlignment="Center" IsReadOnly="True" />
                                 

.... Other Columns ...

</ig:ColumnLayout.Columns>
                            </ig:ColumnLayout>


                        </ig:XamGrid.Columns>
                    </ig:XamGrid>


XAML.CS:

On window Closing event: (Saved user settings)

            using (MemoryStream mStream = PersistenceManager.Save(grid, GetStandardGridPersistenceSettings()))
            {
                mStream.Position = 0;
                using (FileStream fs = new FileStream(@"E:\temp\persistence_scheduling.xml", FileMode.OpenOrCreate))
                {
                     mStream.WriteTo(fs);
                }
            }

On Window Loaded Event: (Load Settings):

            if (!System.IO.File.Exists(@"E:\temp\persistence_scheduling.xml"))
                return;

            using (FileStream fs = File.OpenRead(@"E:\temp\persistence_scheduling.xml"))
            {
                PersistenceManager.Load(grid, fs, GetStandardGridPersistenceSettings());
            }

Common Funtions:

public static PersistenceSettings GetStandardGridPersistenceSettings()
        {
            PersistenceSettings settings = new PersistenceSettings();
            settings.SavePersistenceOptions = PersistenceOption.OnlySpecified;

            // Filter menu
            PropertyNamePersistenceInfo prop = new PropertyNamePersistenceInfo();
            prop.PropertyName = "RowFiltersCollection";
            settings.PropertySettings.Add(prop);

            prop = new PropertyNamePersistenceInfo();
            prop.PropertyName = "Columns[].Key";
            settings.PropertySettings.Add(prop);

            // Filter menu
            prop = new PropertyNamePersistenceInfo();
            prop.PropertyName = "Columns[].FilterColumnSettings";
            settings.PropertySettings.Add(prop);

            // Maybe this is for top filter row?
            prop = new PropertyNamePersistenceInfo();
            prop.PropertyName = "FilteringSettings";
            settings.PropertySettings.Add(prop);

            // Column sort

            prop = new PropertyNamePersistenceInfo();
            prop.PropertyName = "SortingSettings";
            settings.PropertySettings.Add(prop);

        
            // Column order?
            prop = new PropertyNamePersistenceInfo();
            prop.PropertyName = "ColumnMovingSettings";
            settings.PropertySettings.Add(prop);

            // Column width?
            prop = new PropertyNamePersistenceInfo();
            prop.PropertyName = "ColumnResizingSettings";
            settings.PropertySettings.Add(prop);

            // Visible columns?
            prop = new PropertyNamePersistenceInfo();
            prop.PropertyName = "ColumnChooserSettings";
            settings.PropertySettings.Add(prop);

            return settings;
        }

Error On Load Settings:

PersistenceGroup elements don't match elements in stream.

   at Infragistics.Persistence.PersistenceManager.LoadGroup(PersistenceGroup group, Stream stream, PersistenceSettings settings)
   at Infragistics.Persistence.PersistenceManager.Load(DependencyObject obj, Stream stream, PersistenceSettings settings)
   at RxVector.Views.Queues.PreOrder.SchedulingQ.DeSeralizeGridSettings(XamGrid grid, String gridSettings) in E:\TFS\RxVector\RxVector\Views\Queues\PreOrder\SchedulingQ.xaml.cs:line 201
   at RxVector.Views.Queues.PreOrder.SchedulingQ.dgQResult_Loaded(Object sender, RoutedEventArgs e) in E:\TFS\RxVector\RxVector\Views\Queues\PreOrder\SchedulingQ.xaml.cs:line 391
   at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
   at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
   at System.Windows.UIElement.RaiseEvent(RoutedEventArgs e)
   at System.Windows.BroadcastEventHelper.BroadcastEvent(DependencyObject root, RoutedEvent routedEvent)
   at System.Windows.BroadcastEventHelper.BroadcastLoadedEvent(Object root)
   at MS.Internal.LoadedOrUnloadedOperation.DoWork()
   at System.Windows.Media.MediaContext.FireLoadedPendingCallbacks()
   at System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks()
   at System.Windows.Media.MediaContext.RenderMessageHandlerCore(Object resizedCompositionTarget)
   at System.Windows.Media.MediaContext.RenderMessageHandler(Object resizedCompositionTarget)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)