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
140
ContextMenu click is not working properly with PersistenceManager in WPF xamgrid
posted

Hi,

i am using InfragisticsWPF4.v11.2 in my application.

i have use xamgrid in my application. i have use PersistenceManger to save the user  preferences. After i loading my xamgrid from persistenceManager contextmenu click is not working. i have use MVVM pattern in my application 

xaml Code

<ContextMenu x:Key="DataGridRoiSummaryContextMenu">
<MenuItem Header="Update Prediction For Selection" Command="{Binding MenuCommand, Converter={StaticResource NotConverter}}" CommandParameter="UpdatePredictionForSelection" IsEnabled="{Binding HasUpdatePredictionRights}" >

</MenuItem>
<MenuItem Header="Clear Prediction For Selection" Command="{Binding MenuCommand}" CommandParameter="ClearPredictionForSelection" IsEnabled="{Binding HasUpdatePredictionRights}">

</MenuItem>
<Separator/>
<MenuItem Header="Reset Column Order to Default" Command="{Binding MenuCommand}" CommandParameter="ResetColumnOrdertoDefault">

</MenuItem>
</ContextMenu>

Code Behind

  •  save my grid to memorystream 

                                 MemoryStream memoryStream;

                                  memoryStream = PersistenceManager.Save(DataGridRoiSummary);

  • loading from memorystream

                             PersistenceManager.Load(DataGridRoiSummary, memorystreamobject);

can you please help me

Parents
No Data
Reply
  • 138253
    Offline posted

    Hello Ripal,

     

    I am just checking the progress of this issue and was wondering if you managed to achieve your goal or if you need any further assistance on the matter.

Children
  • 225
    posted in reply to Stefan

    I too have experienced the same problem.

    If I deserialize a XamGrid's configuration... the ContextMenu does not load properly.

    I suspect that the issue is related to:

    • If you persist any properties related to the ContextMenu... then there will be an issue with deserialization.  In my case, there is probably a Width or Visibility property in ContextMenu's object tree.
      • If this is the case, then the solution is to be very specific about what you are persisting.
    I don't know if this documentation exists, but it would be helpful if:
    • the PropertyNamePersistenceInfo documentation was clearer
      • what is the default value for options (i.e. PropertyNamePersistenceOptions)? 
    • the PropertyNamePersistenceOptions documentation was clearer
      • could you provide some examples?
    • Postings like XamGrid Persistence Settingsoften contain sample code on how to persist column configurations (e.g. column sort direction, column width, column order, column visibility). Unfortunately, these examples rarely work properly.  For example: you have to do a little voodoo magic if you want to save the columns display order(e.g. ColumnB, ColumnA, ColumnC). Either that or you can save the entire column collection which generates A LOT of data.  And yes you can compress the XML... but then what would be the point of PersistenceSettings.SavePersistenceOptions = PersistenceOption.OnlySpecified;
      • In short, it would be nice if there was better documentation around how to save typical column configurations (e.g. column sort direction, column width, column order, column visibility), without having to save the entire column collection.  
    My apologies if the before mentioned documentation exists.  I have yet to find it.

    PERSISTENCE MANAGER

    <ig:PersistenceManager.Settings>
                <ig:PersistenceSettings SavePersistenceOptions="OnlySpecified" LoadPersistenceOptions="OnlySpecified">
                    <ig:PersistenceSettings.PropertySettings>
                        <ig:PropertyNamePersistenceInfo PropertyName="Width"/> <!-- save any `width` property... anywhere in the XamGrid object graph... including the menu -->
                        <ig:PropertyNamePersistenceInfo PropertyName="Visibility"/>
                        <ig:PropertyNamePersistenceInfo PropertyName="SortingSettings"/>
                    </ig:PersistenceSettings.PropertySettings>
                    <ig:PersistenceSettings.Events>
                        <ig:PersistenceEvents PersistenceLoaded="XamGrid_PersistenceLoaded"/>
                    </ig:PersistenceSettings.Events>
                </ig:PersistenceSettings>
            </ig:PersistenceManager.Settings>

    CONTEXT MENU

    <ig:XamGrid.ContextMenu>
                <ContextMenu>
                    <MenuItem Header="Copy" Command="{x:Static IgCommands:XamGridCommands.CopySelectedRowsToClipboard}" CommandParameter="{Binding Path=PlacementTarget, RelativeSource={RelativeSource AncestorType=ContextMenu}}">
                        <MenuItem.Icon>
                            <Image Width="16" Source="/Resources/Images/Ribbon/Copy.png"/>
                        </MenuItem.Icon>
                    </MenuItem>
                    <MenuItem Header="Copy All"  Command="{x:Static IgCommands:XamGridCommands.CopyAllRowsToClipboard}" CommandParameter="{Binding Path=PlacementTarget, RelativeSource={RelativeSource AncestorType=ContextMenu}}">
                        <MenuItem.Icon>
                            <Image Width="16" Source="/Resources/Images/Ribbon/CopyAll.png"/>
                        </MenuItem.Icon>
                    </MenuItem>
                </ContextMenu>
            </ig:XamGrid.ContextMenu>