void Display() { mChildrenList.ForEach(n => xPanel.UnregisterName(n)); xPanel.Children.Clear(); mChildrenList.Clear(); foreach (var item in mDataSource) { UserDefineInput input = new UserDefineInput(); input.IsEnabled = this.IsEnabled; input.Width = item.Width == 0 ? 220 : (90 + item.Width); input.TagLabel = item.TagLabel; input.Label = item.Label; input.DataType = item.DataType; input.DataValue = item.DataValue; input.Margin = new Thickness(0, 5, 0, 0); input.Name = this.Name + "_" + item.Name; input.DataChangedEvent += new DataChangedEventHandler((sender, e) => { DataChangedEvent?.Invoke(sender, e); if (e.Cancel) { mCanceled = true; } }); xPanel.RegisterName(input.Name, input); mChildrenList.Add(input.Name); xPanel.Children.Add(input); } }
void RebuildDataSource() { if (mCanceled) { return; } mChildrenList.ForEach(n => { UserDefineInput input = xPanel.FindName(n) as UserDefineInput; if (input != null) { mDataSource.FirstOrDefault(m => this.Name + "_" + m.Name == n).DataValue = input.DataValue; } }); }
public UserDefineInput FindInputByName(string name) { UserDefineInput input = xPanel.FindName(this.Name + "_" + name) as UserDefineInput; return(input); }