我正在使用一个需要动态字段来填写表单的应用程序。此表单可能包含多个时间表,每个时间表都包括startDate和finishDate。那么如何在运行时创建的datepicker上设置property_change呢?
if (field.Type == "Timesheets"){
DatePicker sDate = new DatePicker();
sDate.StyleId = field.Name;
sDate.PropertyChanged += sDate_changed;
DatePicker fDate = new DatePicker();
fDate.StyleId = field.Name;
sDate.PropertyChanged += fDate_changed;
}
private async void sDate_changed(object sender, PropertyChangedEventArgs e)
{
// here I don't have access to sdate and fdate
}
2条答案
按热度按时间4si2a6ki1#
这就是
sender
参数的作用tcomlyy62#
After checking your code, I recommend you to add event
DateSelected
for your DatePicker.replace code:
with:
// here I don't have access to sdate and fdate
There are two ways to access
sdate
andfdate
.Method 1(just as Jason posted):
Method 2:
Since you have defined new variables for two
DatePicker
(sdate
andfdate
) , you can use the two variables(sdate
andfdate
) to access the selected date.Please refer to the following code:
Note:
I find that your code variable is being used incorrectly,please replace the following code:
with