只需删除命名空间声明中的额外空格即可。
<Window x:Class="XAMLCalendar.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:XAMLCalendar" mc:Ignorable="d" Title="MainWindow" Height="350" Width="525"> <Grid> <StackPanel Orientation = "Horizontal"> <!-- Create a Calendar that displays dates through Januarary 31, 2015 and has dates that are not selectable. --> <Calendar Margin = "20" SelectionMode = "MultipleRange" IsTodayHighlighted = "false" DisplayDate = "1/1/2015" DisplayDateEnd = "1/31/2015" SelectedDatesChanged = "Calendar_SelectedDatesChanged" xmlns:sys = "clr-namespace:System;assembly=mscorlib"> <Calendar.BlackoutDates> <CalendarDateRange Start = "1/2/2015" End = "1/4/2015"/> <CalendarDateRange Start = "1/9/2015" End = "1/9/2015"/> <CalendarDateRange Start = "1/16/2015" End = "1/16/2015"/> <CalendarDateRange Start = "1/23/2015" End = "1/25/2015"/> <CalendarDateRange Start = "1/30/2015" End = "1/30/2015"/> </Calendar.BlackoutDates> <Calendar.SelectedDates> <sys:DateTime>1/5/2015</sys:DateTime> <sys:DateTime>1/12/2015</sys:DateTime> <sys:DateTime>1/14/2015</sys:DateTime> <sys:DateTime>1/13/2015</sys:DateTime> <sys:DateTime>1/15/2015</sys:DateTime> <sys:DateTime>1/27/2015</sys:DateTime> <sys:DateTime>4/2/2015</sys:DateTime> </Calendar.SelectedDates> </Calendar> </StackPanel> </Grid> </Window>