Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/329.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 存储和检索用户定义的对象,以便在WPF(Devexpress)中隔离存储以在组合框中显示它们_C#_Wpf_Combobox_Devexpress_Isolatedstorage - Fatal编程技术网

C# 存储和检索用户定义的对象,以便在WPF(Devexpress)中隔离存储以在组合框中显示它们

C# 存储和检索用户定义的对象,以便在WPF(Devexpress)中隔离存储以在组合框中显示它们,c#,wpf,combobox,devexpress,isolatedstorage,C#,Wpf,Combobox,Devexpress,Isolatedstorage,我有以下课程: public partial class ContentSet{ [System.NonSerializedAttribute()] private System.Runtime.Serialization.ExtensionDataObject extensionDataField; [System.Runtime.Serialization.OptionalFieldAttribute()] private

我有以下课程:

public partial class ContentSet{

        [System.NonSerializedAttribute()]
        private System.Runtime.Serialization.ExtensionDataObject extensionDataField;

        [System.Runtime.Serialization.OptionalFieldAttribute()]
        private System.Nullable<int> IdField;

        [System.Runtime.Serialization.OptionalFieldAttribute()]
        private string NameField;

        [global::System.ComponentModel.BrowsableAttribute(false)]
        public System.Runtime.Serialization.ExtensionDataObject ExtensionData {
            get {
                return this.extensionDataField;
            }
            set {
                this.extensionDataField = value;
            }
        }

        [System.Runtime.Serialization.DataMemberAttribute()]
        public System.Nullable<int> Id {
            get {
                return this.IdField;
            }
            set {
                if ((this.IdField.Equals(value) != true)) {
                    this.IdField = value;
                    this.RaisePropertyChanged("Id");
                }
            }
        }

        [System.Runtime.Serialization.DataMemberAttribute()]
        public string Name {
            get {
                return this.NameField;
            }
            set {
                if ((object.ReferenceEquals(this.NameField, value) != true)) {
                    this.NameField = value;
                    this.RaisePropertyChanged("Name");
                }
            }
        }

        public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;

        protected void RaisePropertyChanged(string propertyName) {
            System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged;
            if ((propertyChanged != null)) {
                propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
            }
        }
    }
此特定项用于绑定以下组合框的SelectedItem:

<dxe:ComboBoxEdit x:Name="ContentSetCombobox" Grid.Column="1" Height="25" IncrementalFiltering="True" ItemsSource="{Binding ContentSetList}" DisplayMember="Name" AllowUpdateTwoWayBoundPropertiesOnSynchronization="False"  SelectedItem="{Binding SelectedContentSet,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" >
                                            <dxe:ComboBoxEdit.StyleSettings>
                                                <dxe:ComboBoxStyleSettings/>
                                            </dxe:ComboBoxEdit.StyleSettings>
                                        </dxe:ComboBoxEdit>
要检索它,请执行以下操作:

//First get the 'User-Scoped' storage information location refernce in the assembly
                        IsolatedStorageFile isolatedStorage = IsolatedStorageFile.GetMachineStoreForAssembly();
                        //Create a stream reader object to read content from the created isolation location
                        StreamReader srReader = new StreamReader(new IsolatedStorageFileStream("isotest", FileMode.OpenOrCreate, isolatedStorage));
                        {//Open the Isolated Storage
                            if (srReader==null)
                            {
                                MessageBox.Show("No Data Stored");
                            }
                            else
                            {
                                while(!srReader.EndOfStream)
                                {
                                    App.Current.Properties[0] = srReader.ReadLine();
                                }
                            }
                            srReader.Close();
                        }
但我无法检索这些值。
有什么想法吗?

你知道IsolatedStore也存储文件,类似于用户范围设置吗?我不知道。你能给我提供一些关于这方面的内容吗?请参阅以获得概述,尤其是。我一直遵循它,但我找不到任何方法将整个类对象保存到IsolatedStorage中并检索回来。。。
//First Get the 'User-Scoped' storage information location reference in the assembly
                    IsolatedStorageFile isolatedStorage = IsolatedStorageFile.GetMachineStoreForAssembly();
                    //Create a stream writer object to write content in the location
                    StreamWriter srWriter = new StreamWriter(new IsolatedStorageFileStream("isotest", FileMode.Create, isolatedStorage));
                    //check if the Application property collection contains any values
                    if (App.Current.Properties[0] != null)
                    {
                        srWriter.Write(save);
                    }

                    srWriter.Flush();
                    srWriter.Close();
//First get the 'User-Scoped' storage information location refernce in the assembly
                        IsolatedStorageFile isolatedStorage = IsolatedStorageFile.GetMachineStoreForAssembly();
                        //Create a stream reader object to read content from the created isolation location
                        StreamReader srReader = new StreamReader(new IsolatedStorageFileStream("isotest", FileMode.OpenOrCreate, isolatedStorage));
                        {//Open the Isolated Storage
                            if (srReader==null)
                            {
                                MessageBox.Show("No Data Stored");
                            }
                            else
                            {
                                while(!srReader.EndOfStream)
                                {
                                    App.Current.Properties[0] = srReader.ReadLine();
                                }
                            }
                            srReader.Close();
                        }