sc 2 years ago
parent
commit
50197a0a89
  1. 150
      MainWindow.xaml.cs
  2. 2
      ViewModel/MainWindowViewModel.cs

150
MainWindow.xaml.cs

@ -123,157 +123,7 @@ namespace formula_manage
Grid_RRODUCT.ItemsSource = RRODUCTdataTable.DefaultView;
// DataContext defaultView = MACHINEdataTable.DefaultView;
// UnitList = defaultView;
// DataContext = MACHINEdataTable.DefaultView;
// CP_PRODUCT_CODE.ItemsSource= STUFFdataTable.;
/* DataGridTemplateColumn tempColumn = Grid_RRODUCT.Columns[1] as DataGridTemplateColumn;
FrameworkElement element1 = Grid_RRODUCT.Columns[1].GetCellContent(Grid_RRODUCT.Items[1]);
System.Windows.Controls.ComboBox comboBox1 = tempColumn.CellTemplate.FindName("CP_PRODUCT_CODE", element1) as System.Windows.Controls.ComboBox;
comboBox1.ItemsSource = STUFFdataTable.DefaultView;*/
/* SelectionList.Add("Name1");
SelectionList.Add("Name2");*/
// this.Product.DataContext
// this.DataContext = STUFFdataTable;
}
/* public string[] UnitList { get; set; }
private int g_TypeNameDicNo =123; //枪型号名
public int G_TypeNameDicNo
{
get
{
return g_TypeNameDicNo;
}
set
{
g_TypeNameDicNo = value;
}
}
public string G_TypeNameDicNoStr
{
get
{
return gunNameTypeDic[g_TypeNameDicNo]; //查找Dictionary返回它的Value
}
set
{
int selectedIndex = 0;
foreach (KeyValuePair<int, string> pair in gunNameTypeDic)
{
if (pair.ToString().Equals(value)) //对比键值对
{
selectedIndex = pair.Key;
}
}
G_TypeNameDicNo = selectedIndex;
}
}
private Dictionary<int, string> gunNameTypeDic;
public Dictionary<int, string> GunNameTypeDic
{
get
{
return gunNameTypeDic;
}
}
public ObservableCollection<string> SelectionList //ObservableCollection这是一个类,需引用(using System.Collections.ObjectModel)
{
get { return _selectionList; }
set { _selectionList = value; }
}
private ObservableCollection<string> _selectionList = new ObservableCollection<string>(); //这个是实现的重要一步
*/
/* private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
var cb = (sender as System.Windows.Controls.ComboBox);
if (cb == null || cb.Tag == null) return;
int idx = int.Parse(cb.Tag.ToString());
// var bindDataGridDatas = this.Grid_RRODUCT.ItemsSource as BindDataGridData[];//成员变量和这里转换都可以。
// bindDataGridDatas[idx].UnitStr = (string)cb.SelectedItem;//手动保存到数据结构
// bindDataGridDatas[idx].UpdateKBValue(); //联动CoefK值
}
public event PropertyChangedEventHandler PropertyChanged;
private void PropertiesC([CallerMemberName] string propertyName = "")
{
this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
public int Idx { get; set; } = 0;
string unitstr = "Pa";
public string UnitStr
{
get
{
return this.unitstr;
}
set
{
this.unitstr = value;
this.PropertiesC();
}
}
public string[] UnitList { get; set; } = new string[] { "Pa", "kPa", "MPa" };
public static readonly float[][] KBList = new float[][] { new float[] { 1, 1 }, new float[] { 1000, 2 }, new float[] { 1000000, 3 } };
float coefK { get; set; } = 1f;
public float CoefK
{
get
{
return this.coefK;
}
set
{
this.coefK = value;
this.PropertiesC();
}
}
public void UpdateKBValue()
{
int idx = -1;
for (int j = 0; j < this.UnitList.Length; j++)
{
if (this.UnitList[j] == this.unitstr)
{
idx = j; break;
}
}
if (idx == -1) return;
//throw new System.Exception("no Unit in UnitList: unit " + this.UnitStr + " UnitList {" + string.Join(", ", this.UnitList)+"}");
//this.CoefK = BindDataGridData.KBList[idx][0];
}*/
private async void sql_()
{

2
ViewModel/MainWindowViewModel.cs

@ -96,7 +96,7 @@ public class MainWindowViewModel : ViewModelBase
// public ObservableCollection (System.Collections.Generic.List<T> list);
// BarCollection = (ObservableCollection<BarModel>)STUFFdataTable.AsDataView();
// var qwe = STUFFdataTable.DefaultView;
var product = STUFFdataTable.DefaultView;
// var product = STUFFdataTable.DefaultView;
// BarCollection = (ObservableCollection<Product>)STUFFdata;

Loading…
Cancel
Save