reference error using v1 of datagrid

Dec 3, 2008 at 9:36 PM
I have a resource file I'm reading from the application using the Xamlreader and getting the following error:
+  $exception {"Type reference cannot find public type named 'DataGridColumnHeader'.  "} System.Exception {System.Windows.Markup.XamlParseException}


the resource file has the following:

<ResourceDictionary

xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

xmlns:toolkit="http://schemas.microsoft.com/wpf/2008/toolkit">

....

 

<Style x:Key="Style149" TargetType="{x:Type toolkit:DataGridColumnHeader}">

<!-- <Style x:Key="Style149" > -->

<Setter Property="toolkit:DataGridColumnHeader.FontSize" Value="12" />

<Setter Property="toolkit:DataGridColumnHeader.FontFamily" Value="Tahoma" />

<Setter Property="toolkit:DataGridColumnHeader.Foreground">

<Setter.Value>

<SolidColorBrush Color="#FFFF0000" />

</Setter.Value>

</Setter>

<Setter Property="toolkit:DataGridColumnHeader.BorderThickness" Value="1" />

<Setter Property="toolkit:DataGridColumnHeader.BorderBrush">

<Setter.Value>

<SolidColorBrush Color="#FFF2F2F2" />

</Setter.Value>

</Setter>

<Setter Property="toolkit:DataGridColumnHeader.Background">

<Setter.Value>

<SolidColorBrush Color="#FFBAC0C8" />

</Setter.Value>

</Setter>

</Style>

...

 

</ResourceDictionary>

and the code is:

 

mysr =

new StreamReader("style.xaml");

 

SkinDict = (

ResourceDictionary)XamlReader.Load(mysr.BaseStream);

 

 

this.Resources = SkinDict;


I'm having similiar problems with the designer. If I create a base blank project the Window1.xaml files works fine when I add the datagrid using the designer.
When I open a XAML file that is not part of the project - read in at runtime I'm getting errors that the controls were not found "the type 'Canvas' was not found. Verify that you are not missing an assembly reference and that all referenced assemblies have been built"

 

<Canvas

xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

xmlns:dg="http://schemas.microsoft.com/wpf/2008/toolkit">

 

 

x:Name="CanvasMain" Style="{DynamicResource Style1}" Width="730" Height="436" Background="#FFEBECEA" >

 


things were working fine with the datgrid before the V1 changes I just replaced

xmlns:dg="clr-namespace:Microsoft.Windows.Controls;assembly=WpfToolkit"

with

xmlns:dg="http://schemas.microsoft.com/wpf/2008/toolkit">

and using the new WpfToolkit.dll

Coordinator
Dec 4, 2008 at 12:57 AM
Edited Dec 4, 2008 at 1:01 AM
In order to use the namespace http://schemas.microsoft.com/wpf/2008/toolkit, the WPFToolkit assembly needs to be loaded so that its assembly attribute that specifies the default XML namespace for its types is loaded as well. Most likely, this hasn't happened when you tried to load the XAML file.

An easy way to load the assembly is to make a reference to it in your project, if you haven't done so already. Then, before you load the XAML, access a type.

Here's a quick and dirty way of doing that:
var t = typeof(Microsoft.Windows.Controls.DataGrid);
if (t != null) // This ensures that the above line isn't optimized away
{
// Load your XAML
}
Dec 4, 2008 at 7:15 AM
Thanks that fixed the first problem.

I was looking at the second problem - no tellisense working in the designer and found the MSDN help was missing. I reinstalled MSDN Library for VS 2008 SP1 and now the help is there but intellisense is still not working. Intellisense does work in the code windows

Some more information that may have created the problem
I have VS 2008 SP1 installed with MSDN
I then installed CTP of the toolkit
I then install V1 of the toolkit
I then installed Silverlight 2 for Visual Studio 2008