/// <summary> /// JSONを読み込む /// </summary> /// <param name="filePath"></param> private void ReadJson(string filePath) { this.filePath = filePath; var parser = new Microsoft.VisualBasic.FileIO.TextFieldParser(filePath, Encoding.UTF8); using (parser) { var jsonStr = parser.ReadToEnd(); using (var memoryStream = new MemoryStream(Encoding.UTF8.GetBytes(jsonStr))) using (var streamReader = new StreamReader(memoryStream)) { var serializer = new DataContractJsonSerializer(typeof(List <Model.Preset>)); presets = (List <Model.Preset>)serializer.ReadObject(memoryStream); } } presets.Sort((lhs, rhs) => lhs.Title.CompareTo(rhs.Title)); // 読み込んだデータを反映させる titleListView.DataContext = presets; }