level 1
写了一个GPS日历与公历相互转换的UWP程序,程序界面如下图。

点击左侧的calendrView上的任意日期时,右侧的几个comboBox控件显示内容更改为对应日期的GPS历;同样,在右侧的控件中设置一个GPS历时,左侧的calendarView控件也显示对应的公历日期。但是,现在的问题是,如果我通过右侧控件选择的日期不在当前calendarView界面上显示的日期中(也就是图中的2015年12月27日至2016年2月6日),那么calendarView控件并不会自动滑动至所选择的日期。比如我选择2016年第38日(对应2016年2月7日),只有我使用鼠标将calendarView控件滚动至2016年2月的显示界面时,才看到其中的2月7日被选中了(效果如下图)。

(calendarView 控件未自动导航至所选日期)
响应年积日(combox_doy)选择项目的代码如下:
private void combox_doy_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if(true == changeCombox)
{
string strDoy = (string)this.combox_doy.Items[this.combox_doy.SelectedIndex];
int doy = int.Parse(strDoy.Substring(0, 3));
string ydoy = selectDate.Year.ToString().Substring(2) + strDoy.Substring(0, 3);
DateTime date = Ydoy2Date(ydoy);
selectDate = new DateTimeOffset(date, selectDate.Offset);
calendar.SelectedDates[0] = selectDate;
}
}
求大神解救,感激不尽!
2016年01月12日 06点01分
1

点击左侧的calendrView上的任意日期时,右侧的几个comboBox控件显示内容更改为对应日期的GPS历;同样,在右侧的控件中设置一个GPS历时,左侧的calendarView控件也显示对应的公历日期。但是,现在的问题是,如果我通过右侧控件选择的日期不在当前calendarView界面上显示的日期中(也就是图中的2015年12月27日至2016年2月6日),那么calendarView控件并不会自动滑动至所选择的日期。比如我选择2016年第38日(对应2016年2月7日),只有我使用鼠标将calendarView控件滚动至2016年2月的显示界面时,才看到其中的2月7日被选中了(效果如下图)。
(calendarView 控件未自动导航至所选日期)响应年积日(combox_doy)选择项目的代码如下:
private void combox_doy_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if(true == changeCombox)
{
string strDoy = (string)this.combox_doy.Items[this.combox_doy.SelectedIndex];
int doy = int.Parse(strDoy.Substring(0, 3));
string ydoy = selectDate.Year.ToString().Substring(2) + strDoy.Substring(0, 3);
DateTime date = Ydoy2Date(ydoy);
selectDate = new DateTimeOffset(date, selectDate.Offset);
calendar.SelectedDates[0] = selectDate;
}
}
求大神解救,感激不尽!