.net后台代码:
控件的显示与隐藏:
this.dateStart.Visibility = Visibility.Collapsed;//不显示控件
this.dateYear.Visibility = Visibility.Visible;//显示控件
设置控件位置:
this.oildomName.Margin = new Thickness(167, 12, 0, 0);
this.oildomNameList.Margin = new Thickness(212, 12, 0, 0);
this.btnQuery.Margin = new Thickness(322, 12, 0, 0);
this.btnBack.Margin = new Thickness(407, 12, 0, 0);
控件赋值,选定值的设定:
for (int ii = DateTime.Today.Year; ii >= 1980; ii--)
{
string item = string.Format("{0}年", ii.ToString());
// this.dateYear.Items.Add(item);
if (item != sClickReportDate)
{
this.dateYear.Items.Add(item);
}
else
{
ComboBoxItem cbi1 = new ComboBoxItem();
cbi1.SetValue(ComboBoxItem.ContentProperty, sClickReportDate);
this.dateYear.Items.Add(cbi1);
//下拉框赋选定值
this.dateYear.SelectedItem = cbi1;
}
}