title: Silverlight Error: AG_E_UNKNOWN_ERROR
body: <p>I'm getting a <code>AG_E_UNKNOWN_ERROR</code> when running my Silverlight project. The project is ported from WPF, and from what I can gather around the web, I'd assume it's related to something invalid in my XAML </p>
  
  <p><strong>EDIT</strong> C# Control sources can be found here: <a href="http://code.assembla.com/lth-aarhus/subversion/nodes/WpfCalendar/SilverlightCalendar/Controls?rev=13" rel="nofollow noreferrer">SilverlightCalendar/Controls</a></p>
  
  <p>Here's Generic.xaml, the styles for my application.</p>
  
  <pre><code>&lt;ResourceDictionary
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:c="clr-namespace:SilverlightCalendar.Controls"&gt;
  
      &lt;Style TargetType="{c:CalendarTimeslotItem}"&gt;
          &lt;Setter Property="Content" Value="{Binding}" /&gt;
          &lt;Setter Property="Background" Value="White" /&gt;
          &lt;Setter Property="Template"&gt;
              &lt;Setter.Value&gt;
                  &lt;ControlTemplate TargetType="{c:CalendarTimeslotItem}"&gt;
                      &lt;Border Background="{TemplateBinding Background}"
                              BorderBrush="#A5BFE1"
                              BorderThickness="0,0.5,0,0.5"
                              x:Name="bd"
                              Height="22"&gt;
                      &lt;/Border&gt;
                  &lt;/ControlTemplate&gt;
              &lt;/Setter.Value&gt;
          &lt;/Setter&gt;
      &lt;/Style&gt;
  
      &lt;Style TargetType="{c:CalendarLedgerItem}"&gt;
          &lt;Setter Property="Template"&gt;
              &lt;Setter.Value&gt;
                  &lt;ControlTemplate TargetType="{c:CalendarLedgerItem}"&gt;
                      &lt;Border Background="#E3EFFF"
                              BorderBrush="#6593CF"
                              BorderThickness="0,0,1,1"
                              Height="44" Width="50"&gt;
                          &lt;StackPanel Orientation="Horizontal" 
                                      VerticalAlignment="Center" 
                                      HorizontalAlignment="Center"&gt;
                              &lt;TextBlock Text="{TemplateBinding TimeslotA}" 
                                         Foreground="#9493CF" FontSize="16" Margin="0,3,0,0"/&gt;
                              &lt;TextBlock Text="{TemplateBinding TimeslotB}" 
                                         Foreground="#9493CF"  Margin="1.5,0,0,0"/&gt;
                          &lt;/StackPanel&gt;
                      &lt;/Border&gt;
                  &lt;/ControlTemplate&gt;
              &lt;/Setter.Value&gt;
          &lt;/Setter&gt;
      &lt;/Style&gt;
  
      &lt;Style TargetType="{c:CalendarDay}"&gt;
          &lt;Setter Property="ItemsPanel"&gt;
              &lt;Setter.Value&gt;
                  &lt;ItemsPanelTemplate&gt;
                      &lt;c:TimeslotPanel /&gt;
                  &lt;/ItemsPanelTemplate&gt;
              &lt;/Setter.Value&gt;
          &lt;/Setter&gt;
          &lt;Setter Property="Template"&gt;
              &lt;Setter.Value&gt;
                  &lt;ControlTemplate TargetType="{c:CalendarDay}"&gt;
                      &lt;Border Background="{TemplateBinding Background}"
                              BorderBrush="{TemplateBinding BorderBrush}"
                              BorderThickness="{TemplateBinding BorderThickness}"&gt;
                          &lt;Grid&gt;
                              &lt;StackPanel x:Name="PART_CalendarTimeslots" /&gt;
                              &lt;ItemsPresenter /&gt;
                          &lt;/Grid&gt;
                      &lt;/Border&gt;
                  &lt;/ControlTemplate&gt;
              &lt;/Setter.Value&gt;
          &lt;/Setter&gt;
      &lt;/Style&gt;
  
      &lt;Style TargetType="{c:CalendarLedger}"&gt;
          &lt;Setter Property="Template"&gt;
              &lt;Setter.Value&gt;
                  &lt;ControlTemplate TargetType="{c:CalendarLedger}"&gt;
                      &lt;Border Background="{TemplateBinding Background}"
                              BorderBrush="{TemplateBinding BorderBrush}"
                              BorderThickness="{TemplateBinding BorderThickness}"&gt;
                          &lt;StackPanel x:Name="PART_CalendarLedgerItems" /&gt;
                      &lt;/Border&gt;
                  &lt;/ControlTemplate&gt;
              &lt;/Setter.Value&gt;
          &lt;/Setter&gt;
      &lt;/Style&gt;
  
      &lt;Style TargetType="{c:Calendar}"&gt;
          &lt;Setter Property="Template"&gt;
              &lt;Setter.Value&gt;
                  &lt;ControlTemplate TargetType="{c:Calendar}"&gt;
                      &lt;Border Background="#E3EFFF"
                              BorderBrush="#6593CF"
                              BorderThickness="2,2,2,2"&gt;
                          &lt;Grid&gt;
                              &lt;Grid.ColumnDefinitions&gt;
                                  &lt;ColumnDefinition Width="50" /&gt;
                                  &lt;ColumnDefinition Width="*" /&gt;
                              &lt;/Grid.ColumnDefinitions&gt;
                              &lt;Grid.RowDefinitions&gt;
                                  &lt;RowDefinition Height="*" /&gt;
                              &lt;/Grid.RowDefinitions&gt;
                              &lt;Border BorderBrush="#6593CF" BorderThickness="0,0,0,1" 
                                      Grid.Column="0" Grid.Row="1" /&gt;
                              &lt;Border BorderBrush="#6593CF" BorderThickness="0,0,0,1" 
                                      Grid.Column="1" Grid.Row="1" /&gt;
                              &lt;ScrollViewer Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="2"&gt;
                                  &lt;Grid&gt;
                                      &lt;Grid.ColumnDefinitions&gt;
                                          &lt;ColumnDefinition Width="50" /&gt;
                                          &lt;ColumnDefinition Width="*" /&gt;
                                      &lt;/Grid.ColumnDefinitions&gt;
  
                                      &lt;c:CalendarLedger Grid.Column="0" /&gt;
                                      &lt;c:CalendarDay Grid.Column="1" x:Name="PART_CalendarDay" /&gt;
                                  &lt;/Grid&gt;
                              &lt;/ScrollViewer&gt;
                          &lt;/Grid&gt;
                      &lt;/Border&gt;
                  &lt;/ControlTemplate&gt;
              &lt;/Setter.Value&gt;
          &lt;/Setter&gt;
      &lt;/Style&gt;
  
      &lt;Style TargetType="{c:CalendarAppointmentItem}"&gt;
          &lt;Setter Property="StartTime" Value="{Binding StartTime}" /&gt;
          &lt;Setter Property="EndTime" Value="{Binding EndTime}" /&gt;
          &lt;Setter Property="Width" Value="{Binding ActualWidth, ElementName=CalendarTimeslots}" /&gt;
          &lt;Setter Property="Template"&gt;
              &lt;Setter.Value&gt;
                  &lt;ControlTemplate TargetType="{c:CalendarAppointmentItem}"&gt;
                      &lt;Grid&gt;
                          &lt;Grid.ColumnDefinitions&gt;
                              &lt;ColumnDefinition Width="300" /&gt;
                              &lt;ColumnDefinition Width="300" /&gt;
                          &lt;/Grid.ColumnDefinitions&gt;
                          &lt;Grid.RowDefinitions&gt;
                              &lt;RowDefinition Height="*" /&gt;
                          &lt;/Grid.RowDefinitions&gt;
                          &lt;Border Grid.Row="0" 
                                  Grid.Column="{Binding Column}" 
                                  Grid.ColumnSpan="{Binding ColumnSpan}"
                                  CornerRadius="4,4,4,4" 
                                  BorderThickness="1,1,1,1" 
                                  BorderBrush="#5D8CC9" 
                                  Background="{Binding Background}"
                                  Margin="1,1,5,1" 
                                  Padding="5,5,5,5"&gt;
                              &lt;Border.Effect&gt;
                                  &lt;DropShadowEffect Opacity="0.5" /&gt;
                              &lt;/Border.Effect&gt;
                              &lt;TextBlock 
                                  IsHitTestVisible="False"
                                  Foreground="{Binding Foreground}"
                                  VerticalAlignment="Top"
                                  MaxHeight="20"
                                  LineHeight="20"
                                  FontFamily="Segoe UI" 
                                  FontSize="12.75" 
                                  FontWeight="DemiBold"
                                  FontStretch="Medium"
                                  TextWrapping="WrapWithOverflow"
                                  Text="{Binding Subject}" /&gt;                            
                          &lt;/Border&gt;
                      &lt;/Grid&gt;
                  &lt;/ControlTemplate&gt;
              &lt;/Setter.Value&gt;
          &lt;/Setter&gt;
      &lt;/Style&gt;
  &lt;/ResourceDictionary&gt;
  </code></pre>