// c# code 通过 grid_main.Children 完成页码的切换 启用 switch (item.data) { case (int)TREE_ITEM_INDEX.Solution: break; case (int)TREE_ITEM_INDEX.Sensor: grid_main.Children.Clear(); grid_main.Children.Add(new UCSensor()); break; case (int)TREE_ITEM_INDEX.Standard: break; case (int)TREE_ITEM_INDEX.measure_programe: break; case (int)TREE_ITEM_INDEX.coeff: grid_main.Children.Clear(); grid_main.Children.Add(new UCCoeff()); break; case (int)TREE_ITEM_INDEX.measure_step: break; case (int)TREE_ITEM_INDEX.zero_step: break; case (int)TREE_ITEM_INDEX.preelaboration: break; case (int)TREE_ITEM_INDEX.measure: break; default: Log.Warning("tree index not found: " + item.data.ToString()); break; }
Without specifying public the class is implicitly internal. This means that the class is only visible inside the same assembly. When you specify public, the class is visible outside the assembly.
It is also allowed to specify the internal modifier explicitly:
public IdInfo(int IdNumber) { this.IdNumber = IdNumber; } } public class Person { public int Age; public string Name; public IdInfo IdInfo;
public Person ShallowCopy() { return (Person) this.MemberwiseClone(); }
public Person DeepCopy() { Person other = (Person) this.MemberwiseClone(); other.IdInfo = new IdInfo(IdInfo.IdNumber); other.Name = String.Copy(Name); return other; } }
// Create an instance of Person and assign values to its fields. Person p1 = new Person(); p1.Age = 42; p1.Name = "Sam"; p1.IdInfo = new IdInfo(6565);
// Perform a shallow copy of p1 and assign it to p2. Person p2 = p1.ShallowCopy();
// $ is short-hand for String.Format and is used with string interpolations, // which is a new feature of C# 6. As used in your case, it does nothing, just as string.Format() would do nothing.
var anInt = 1; var aBool = true; var aString = "3"; var aFloat = 12.3456 var formated = string.Format("{0},{1},{2}", anInt, aBool, aString);
// same result var formated = $"{anInt},{aBool},{aString},{aFloat:f2}"; aFloat = 12.34
// do work textBox.AppendText("Work finished\r\n"); // better way than Text += according to msdn // do more textBox.AppendText("One more message\r\n");
Label is ContentControl which means that you can set anything as a content for it. Absolutely anything including strings, numbers, dates, other controls, images, shapes, etc. TextBlock can handle only strings.
TextBlock is not a control Even though TextBlock lives in the System.Windows.Controls namespace, it is not a control. It derives directly from FrameworkElement. Label, on the other hand, derives from ContentControl. This means that Label can:
Be given a custom control template (via the Template property).
Display data other than just a string (via the Content property).
Apply a DataTemplate to its content (via the ContentTemplate property).
Do whatever else a ContentControl can do that a FrameworkElement cannot.
Label text is grayed out when disabled Label supports access keys Label is much heavier than TextBlock