Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > Avalon

Vista - MonthCalendar in XAML using WindowsFormsHost

 
 
Old 03-27-2006   #1 (permalink)
craig kelly-soens www.xpectworld.com


 
 

MonthCalendar in XAML using WindowsFormsHost

MonthCalendar in XAML using WindowsFormsHost

hi,
For all those disappointed in the dropped MonthCalendar and needing it like
me,
here is a workaround, use the WinForm one instead !, we ARE just dealing
with classes you know !

Reference WindowsFormsIntegration.dll
i used C:\Program Files\Reference Assemblies\Microsoft\WPF\v3.0

<!-- in XAML create a Canvas as a container -->
<Page....
<StackPanel...
<Canvas x:Name="canvasContainer"></Canvas>
</StackPanel>
</Page>


//in Code
using System.Windows.Forms.Integration;

System.Windows.Forms.MonthCalendar monthCalendarStart = new
System.Windows.Forms.MonthCalendar();

WindowsFormsHost oWindowsFormsHost = new WindowsFormsHost();
oWindowsFormsHost.Height = 100;
oWindowsFormsHost.Width = 300;
oWindowsFormsHost.Children.Add(monthCalendarStart);
oWindowsFormsHost.SetValue(Canvas.TopProperty, 5.0);
oWindowsFormsHost.SetValue(Canvas.LeftProperty, 5.0);
this.canvasContainer.Children.Add(oWindowsFormsHost);

DateTime oDateTime = monthCalendarStart.SelectionStart.Date; // and get the
value as normal
--------------------------
If you are using this stuff I'd like to chat to you, basically any Vista
Technologies actually, for some real projects, please see website for
contacts.

with much thanks to Mike Henderlight and his excellent and amusing blog
http://blogs.msdn.com/mhendersblog/

cheers,

craig kelly-soens - Windows Vista WinFx XAML .Net Technical Evangelist
http://www.XpectWorld.com - customised "super-easy to use" Windows Vista
based .Net software & consultancy and the Xtensions Customer Xperience
Manager database

My System SpecsSystem Spec
 

Thread Tools


Similar Threads
Thread Forum
MonthCalendar .NET General
Extend MonthCalendar Control .NET General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46