我試圖在簡單的WPF應用程序中使用使用winforms的MonthCalendar控件。我發現通過使用WindowsFormsHost,可以在wpf應用程序中使用winforms控件。它適用於WinForms的內置控件,但是當我嘗試實例化此控件MonthCalendar的對象時,出現錯誤,提示「無法實例化MonthCalendar的對象」。試圖在wpf應用程序中使用winforms控件
有關爲什麼會發生這種情況以及如何解決這個問題的任何建議?在XAML 爲的MonthCalendar的源代碼可在http://www.codeproject.com/Articles/10840/Another-Month-Calendar?msg=2298161#xx2298161xx
林實例吧:
<Window x:Class="MonthCalendarTest.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:wf="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"
xmlns:pc="clr-namespace:Pabo.Calendar"
Title="MainWindow" Height="350" Width="525">
<Grid Height="65" Width="280">
<WindowsFormsHost Margin="0,0,12,12" Height="100">
<pc:MonthCalendar></pc:MonthCalendar>
</WindowsFormsHost>
</Grid>
你如何在代碼或xaml中實例化?如果它的代碼,也許你可以添加該代碼到你的問題。 – Surfbutler
對不起,我忘了提及,我在xaml中實例化它,請看我編輯的帖子。 – user1340852
'MonthCalendar'是否有無參數的構造函數? –