Xceed DataGrid for WPF v7.3 Documentation
Xceed.Wpf.DataGrid Assembly / Xceed.Wpf.DataGrid Namespace / DataGridControl Class / LoadUserSettings Method
A reference to a SettingsRepository that contains the settings that are to be re-applied to the grid.
A UserSettings value representing the settings that are to be re-applied to the grid.
Example


In This Topic
    LoadUserSettings Method
    In This Topic
    Loads the settings persisted in a settings repository and re-applies them to the grid.
    Syntax
    'Declaration
     
    Public Sub LoadUserSettings( _
       ByVal settingsRepository As SettingsRepository, _
       ByVal settings As UserSettings _
    ) 
    'Usage
     
    Dim instance As DataGridControl
    Dim settingsRepository As SettingsRepository
    Dim settings As UserSettings
     
    instance.LoadUserSettings(settingsRepository, settings)
    public void LoadUserSettings( 
       SettingsRepository settingsRepository,
       UserSettings settings
    )

    Parameters

    settingsRepository
    A reference to a SettingsRepository that contains the settings that are to be re-applied to the grid.
    settings
    A UserSettings value representing the settings that are to be re-applied to the grid.
    Example

    All examples in this topic assume that the grid is bound to the Orders table of the Northwind database, unless stated otherwise.

    The following example demonstrates how to persist and load settings using an XML serializer.The following code provides the implementation required to persist and load settings using the XmlSerializer class. The following code provides the implementation required to persist and load settings using the XmlSerializer class.
    <Grid xmlns:xcdg="http://schemas.xceed.com/wpf/xaml/datagrid">
      <Grid.Resources>
         <xcdg:DataGridCollectionViewSource x:Key="cvs_orders"
                                            Source="{Binding Source={x:Static Application.Current}, Path=Orders}" />
    
      </Grid.Resources>
      <DockPanel>
         <StackPanel Orientation="Horizontal"
                     DockPanel.Dock="Top">
            <Button Content="Save Settings"
                    Click="SaveSettings" />
            <Button Content="Load Settings"
                    Click="LoadSettings" />
         </StackPanel>
         <xcdg:DataGridControl x:Name="OrdersGrid"
            ItemsSource="{Binding Source={StaticResource cvs_orders}}">
         </xcdg:DataGridControl>
      </DockPanel>
    </Grid>
    Private Sub SaveSettings( ByVal sender As Object, ByVal e As RoutedEventArgs )
    
    
      Dim settings As New SettingsRepository()
      Me.OrdersGrid.SaveUserSettings( settings, UserSettings.All )
    
      Dim serializer As New XmlSerializer( GetType( SettingsRepository ) )
    
      Using stream As New FileStream( "d:\settings.xml", FileMode.CreateNew )
        serializer.Serialize( stream, settings )
      End Using
    End Sub
    
    Private Sub LoadSettings( ByVal sender As Object, ByVal e As RoutedEventArgs )
    
    
      Dim settings As SettingsRespository
    
      Using stream As New FileStream( "d:\settings.xml", FileMode.Open )
        Dim serializer As New XmlSerializer( GetType( SettingsRepository ) )
        settings = TryCast( serializer.Deserialize( stream ), SettingsRepository )
      End Using
    
      Me.OrdersGrid.LoadUserSettings( settings, UserSettings.All )
    End Sub
    private void SaveSettings( object sender, RoutedEventArgs e )
    {
    
    
     SettingsRepository settings = new SettingsRepository();   
     this.OrdersGrid.SaveUserSettings( settings, UserSettings.All );
    
     XmlSerializer serializer = new XmlSerializer( typeof( SettingsRepository ) );
    
     using( FileStream stream = new FileStream( "d:\\settings.xml", FileMode.CreateNew ) )
     {
       serializer.Serialize( stream, settings );
     }
    }
    
    private void LoadSettings( object sender, RoutedEventArgs e )
    {
    
    
     SettingsRepository settings;
     using( FileStream stream = new FileStream( "d:\\settings.xml", FileMode.Open ) )
     {
       XmlSerializer serializer = new XmlSerializer( typeof( SettingsRepository ) );
       settings = serializer.Deserialize( stream ) as SettingsRepository;
     }
    
     this.OrdersGrid.LoadUserSettings( settings, UserSettings.All );
    }
    Requirements

    See Also

    Reference

    DataGridControl Class
    DataGridControl Members
    SaveUserSettings Method

    DataGrid Fundamentals

    Persisting Settings