问题描述
您好。 我已在CalendarViewDayItemChanging中实现了代码,以更改某些日期背景颜色。 代码可以找到,但颜色会在日历视图中的后续日期重复显示。 例如,我在12月21日的背景下更改
。 相同的背景将出现在次年的3月,然后是6月,然后是9月和之后。 为了验证代码是否正常工作,我将更改日期
输出到调试器窗口,12月21日是唯一更改的日期。 有什么我做错了或者这是CalendarView中的问题? 代码如下。 感谢您的帮助。
Hello. I have implemented code in the CalendarViewDayItemChanging to change certain dates background color. The code works find, although the colors are repeating themselves in later dates in the Calendar view. For example, I change the background of December 21st. The same background will appear on day in March of the following year and then again in June and then again in September and on and on. To verify the code is working correctly, I have the dates that are changed output to the debugger window and December 21st is the only date that gets changed. Is there something I'm doing wrong or is this a problem in the CalendarView? The code is below. Thanks for any help.
If (Date.Compare(Date.Parse(Date.Parse(dd.Item(i).field1).ToString("yyyy-MM-dd")), Date.Parse(args.Item.Date.ToLocalTime.ToString("yyyy-MM-dd"))) = 0) Then
Debug.WriteLine("Date Match " & args.Item.Date.ToLocalTime.ToString("yyyy-MM-dd"))
If CInt(dd.Item(i).field3) > 0 Then
If (CInt(dd.Item(i).field4) > 0) Then
args.Item.Background = New SolidColorBrush(Windows.UI.Colors.LightGreen)
ElseIf (CInt(dd.Item(i).field5) > 0) Then
args.Item.Background = New SolidColorBrush(Windows.UI.Colors.LightYellow)
ElseIf (CInt(dd.Item(i).field6) > 0) Then
args.Item.Background = New SolidColorBrush(Windows.UI.Colors.LightPink)
End If
ElseIf CInt(dd.Item(i).field2) > 0 Then
args.Item.Background = New SolidColorBrush(Windows.UI.Colors.LightSlateGray)
End If
End If
CEDeveloper
CEDeveloper
推荐答案
请阅读粘贴帖子,尤其是
发布指南:主题行标签和
Windows 10 SDK和工具的已知问题
Please read the sticky posts, especially theGuide to posting: subject line tags and Known Issues for Windows 10 SDK and Tools
我们需要知道你项目的类型,你需要自己为标题添加标签。
We need to know your project's type, and you would need to add tag to title by yourself.
我检查了你的代码,但我无法理解"某些日期"是什么。什么是"dd.Item(i).field1"?
I have checked your code, but I could not understand what the "certain dates" is. And what’s the "dd.Item(i).field1"?
请提供有关您问题的更多详细信息。
Please provide more details about your questions.
最好的问候,
Xavier Eoro
Xavier Eoro
这篇关于[UWP] [VB] CalendarView重复CalendarViewDayItem更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!