[英]Wpf calendar show many months
i need to show at least two months (secuential) at the same time in the same calendar but can't find to do this with the calentdar control of WPF. 我需要在同一日历中同时显示至少两个月(secure),但无法使用WPF的calentdar控件执行此操作。
How can I Do that ? 我怎样才能做到这一点 ?
Why not add two calendars and two way bind the displaydate of the second to the displaydate of the first using the following converter and 1 as the ConverterParameter) 为什么不添加两个日历,并使用以下转换器和1作为ConverterParameter将第二个的显示日期绑定到第一个的显示日期?
Public Class AddMonthConverter
Implements Windows.Data.IValueConverter
Public Function Convert(ByVal value As Object, ByVal targetType As System.Type, ByVal parameter As Object, ByVal culture As System.Globalization.CultureInfo) As Object Implements System.Windows.Data.IValueConverter.Convert
Return addMonths(value, targetType, parameter, True)
End Function
Public Function ConvertBack(ByVal value As Object, ByVal targetType As System.Type, ByVal parameter As Object, ByVal culture As System.Globalization.CultureInfo) As Object Implements System.Windows.Data.IValueConverter.ConvertBack
Return addMonths(value, targetType, parameter, False)
End Function
Private Function addMonths(ByVal value As Object, ByVal targetType As System.Type, ByVal parameter As Object, ByVal isIncrease As Boolean) As Object
If Not (targetType Is GetType(DateTime?) OrElse targetType Is GetType(DateTime)) Then
Throw New InvalidOperationException("The target and value must be a DateTime?")
Else
Dim dteValue As DateTime? = CType(value, DateTime?)
Dim intMonthsToAdd As Int32
If parameter Is Nothing OrElse Int32.TryParse(parameter.ToString, intMonthsToAdd) = False Then
intMonthsToAdd = -1
End If
If dteValue.HasValue Then
If isIncrease Then
Return dteValue.Value.AddMonths(intMonthsToAdd)
Else
Return dteValue.Value.AddMonths(-intMonthsToAdd)
End If
Else
Return dteValue
End If
End If
End Function
End Class
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.