TimePicker Windows Phone 7 的 NullReferenceException
我在我的应用程序中使用时间选择器,但每当我给它一个默认值时,NullReferenceException就会出现在valuechange函数中。我的代码
private void timePicker1_ValueChanged(object sender, DateTimeValueChangedEventArgs e)
{
var time = (DateTime)timePicker1.Value;
// time.ToShortTimeString()
MessageBox.Show(time.ToString("H:mm"));
writeTimeFile(time);
ResetAlarm();
setTheAlarm();
}
实际上是每当我启动我的应用程序时,时间选择器显示当前时间,但我希望它显示一些特定值,比如00:00或 12:00。
I am using timepicker in my application but whenever I give it a default value then NullReferenceException appears in valuechange function.My code is
private void timePicker1_ValueChanged(object sender, DateTimeValueChangedEventArgs e)
{
var time = (DateTime)timePicker1.Value;
// time.ToShortTimeString()
MessageBox.Show(time.ToString("H:mm"));
writeTimeFile(time);
ResetAlarm();
setTheAlarm();
}
Actually whenever I start my application,the timepicker shows current time but I want it to show some specific value say 00:00 or 12:00.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
确保您正确设置时间选择器对象的值。这对我有用。另请验证其他内容是否不会引发
NullReferenceException
。Make sure you are setting the value of your time picker object correctly. This worked for me. Also verify something else isn't throwing the
NullReferenceException
.