0
私は、ユーザーが実動データを入力できるようにするWPFアプリケーションを用意しています。WPFパフォーマンスの問題
そのため、WPF Toolkit Accordionを使用するUsercontrolを作成しました。私は15のアコーディオンアイテムを作成します。各アイテムにはStackpanelと5-10個のテキストボックスがあります。
これらのコントロールのうち12個をメインのコンテンツコントロールに追加すると、約10秒かかります。
この現象の原因は何ですか?
public XXXMeasurementControl(Measurement meas)
{
InitializeComponent();
if (meas.ID == -2)
{
LineNameTextBlock.Text = "Total";
}
else
{
LineNameTextBlock.Text = meas.MeasureDate.ToString("HH:mm") + " - " + meas.MeasureDate.AddHours(1).ToString("HH:mm");
}
this.cells = meas.MainCells;
this.meas = meas;
Binding b = new Binding();
Remark.DataContext = Meas;
b.Mode = BindingMode.TwoWay;
b.Path = new PropertyPath("Remark");
BindingOperations.SetBinding(Remark, TextBox.TextProperty, b);
//Create Cells Start
foreach (Cell c in cells)
{
//Creating Textboxes & Bindings for Stations from Maincells
if (c.Name != "OQC")
{
//Setting Qualified Overall (=Qualified from Cell Appearance Check)
Common.BindTextBlock(QualifiedOverallTextBlock, c, "Qualified");
if (c.Name.Contains("Appearance Check"))
Common.BindTextBlock(QualifiedOverallTextBlock, c, "Qualified");
//Setting Scrap Rate (=Waste from Cell Acoustic Test)
if (c.Name.Contains("Acoustic Test"))
Common.BindTextBlock(ScrapRateTextBlock, c, "WasteRate");
AccordionItem aci = new AccordionItem();
StackPanel sp = new StackPanel();
StackPanel groupData = new StackPanel();
StackPanel all = new StackPanel();
all.Children.Add(sp);
all.Children.Add(groupData);
if (c.Stations != null)
//All Single Cell Line Controls
if (meas.ID != -2)
{
for (int i = 0; i < c.Stations.Count; i++)
{
NumberTextbox t = Common.CreateNumberTextbox(c.Stations[i], "Value", BindingMode.TwoWay, false, null, 80, 22);
t.LostFocus += new RoutedEventHandler(t_LostFocus);
c.Stations[i].PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(LineControl_PropertyChanged);
//Handling if Qualified Field is Editable
if (c.Stations[i].Name.Contains("Qualified"))
{
t.Background = new SolidColorBrush(Colors.BlanchedAlmond);
groupData.Children.Add(t);
}
else
{
sp.Children.Add(t);
}
}
}
groupData.Children.Add(Common.CreateNumberTextbox(c, "RejectQty", BindingMode.OneWay, true,null, 80, 22));
groupData.Children.Add(Common.CreateNumberTextbox(c, "PassRate", BindingMode.OneWay, true, new SolidColorBrush(Colors.BlanchedAlmond), 80, 22));
groupData.Children.Add(Common.CreateNumberTextbox(c, "RejectRate", BindingMode.OneWay, true, new SolidColorBrush(Colors.BlanchedAlmond), 80, 22));
aci.Header = "";
aci.Content = all;
MainCellsAccordion.Items.Add(aci);
}
}
}