public SixBandResistorViewModel() { BandValues = new ObservableCollection <ResistorBand>(); ToleranceBand = new ObservableCollection <ResistorBand>(); TempCoeffBand = new ObservableCollection <ResistorBand>(); MyData1 _context = new MyData1(); foreach (var band in _context.Band1Vals) { // Exclude silver and gold bands if (!band.Color.Equals("#FFFFD700") && !band.Color.Equals("#c0c0c0")) { BandValues.Add(band); } // Exclude black and white bands if (!band.Color.Equals("#000000") && !band.Color.Equals("#FFFFFF")) { ToleranceBand.Add(band); } // Exclude yellow, white, gold, silver if (!band.Color.Equals("#ffff00") && !band.Color.Equals("#FFFFFF") && !band.Color.Equals("#FFFFD700") && !band.Color.Equals("#c0c0c0")) { TempCoeffBand.Add(band); } } }
public ResistorBandViewModel() { Values = new ObservableCollection <ResistorBand>(); MyData1 _context = new MyData1(); foreach (var band in _context.Band1Vals) { Values.Add(band); } }
public HumanViewModels() { Humans = new ObservableCollection <Human>(); MyData1 _context = new MyData1(); foreach (var human in _context.Humans) { Humans.Add(human); } }
private void btn1_Click(object sender, RoutedEventArgs e) { StringBuilder sb = new StringBuilder(); MyData1 data = new MyData1(); sb.AppendLine("直接创建对象:"); sb.AppendLine("myName2:" + data.MyName2); sb.AppendLine("myNmae3:" + data.myName3); //myName3是private,无法获取 sb.AppendLine("Telephone:" + data.Telephone); Service2Client client = new Service2Client(); MyData1 data1 = client.GetMyData1(); sb.AppendLine("通过服务获取对象:"); sb.AppendLine("myName2:" + data1.MyName2); sb.AppendLine("myNmae3:" + data1.myName3); //myName3是private,无法获取 sb.AppendLine("Telephone:" + data1.Telephone); textBlock.Text = sb.ToString(); }