不知为啥原因,WPF中没有Month Calendar月历控件,那么可否实现在WPF中也可以用上MonthCalendar呢?
还记得吗?在前面一篇文章“WinForm控件与WPF控件的交互”中,我们首先定义:xmlns:wf="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms,然后使用
WindowsFormsHost标签实现了WinForm控件与WPF控件的交互。
我们举一返三来解决Month Calendar月历控件的问题:
XAML代码:
(这里使用了codeproject.com网站上的一个Dll,你可以在这里下载它:http://www.codeproject.com/cs/miscctrl/MonthCalendar.asp)
<Window x:Class="MonthCalendarDemo"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:wfi="clr-namespace:System.Windows.Forms.Integration;assembly=WindowsFormsIntegration"
xmlns:monthControl="clr-namespace:Pabo.Calendar;assembly=MonthCalendar"
Title="Month Calendar Demo" Height="500" Width="500">
<Grid>
<wfi:WindowsFormsHost>
<monthControl:MonthCalendar />
</wfi:WindowsFormsHost>
</Grid>
</Window>
BTW, 在网上也有如下的资源:
终于找到了一个WPF中的日历控件
共享代码:WPF的日历控件
希望对你有用,呵!(如果有时间的话,我再写一个带农历的万年历控件,就类似这个:带农历的中国万年历制作 ,这是我两年多前写的了,算法都是现成的,嘿嘿)