Binding sample causes error in VS - workaround doesn't seem to

Just FYI

Steps:

Extract and Build -Binding to a Non-Text Property Sample

ms-help://MS.MSSDK.1033/MS.WinFXSDK.1033/wpf_samples/html/c08d47f3-610a-4dae-911c-7c201ba1909e.htm

Result:

Error 1 Assembly '' could not be found. Are you missing an assembly reference? C:\Monarch\Sandbox\nball\WinFx\BindNonText\CSharp\Page1.xaml 5 11 BindNonTextProperty

Error 2 Type 'c:MyData' could not be found. Are you missing an assembly reference? C:\Monarch\Sandbox\nball\WinFx\BindNonText\CSharp\Page1.xaml 8 6 BindNonTextProperty

Note:MyData is part of the project.<DockPanel.Resources>

--

Here's the XAML

<c:MyDatax:Key="myDataSource"/>

</DockPanel.Resources>

<DockPanelDockPanel.Dock="Top"HorizontalAlignment="Left"VerticalAlignment="Top">

<DockPanel.DataContext>

<BindingSource="{StaticResource myDataSource}"/>

</DockPanel.DataContext>

<ButtonBackground="{Binding Path=ColorName}"Width="150"Height="30">I am bound to be RED!</Button>

</DockPanel>

</DockPanel>

--

Might just be a problem with this declaration

xmlns:c="clr-namespace:SDKSample"

I was able to run the app. properly.

[4163 byte] By [NickNotYet] at [2008-3-6]
# 1

This is an example of a known load limitation. This is documented here: http://channel9.msdn.com/wiki/default.aspx/Cider.MayCTPXAMLLoadLimitations

Specifically, have a look at: http://channel9.msdn.com/wiki/default.aspx/Cider.MayCTPProjectLimitations, in project types are not yet supported in Cider.

Sorry for the inconvenience.

JimNakashima-MSFT at 2007-9-10 > top of Msdn Tech,Visual Studio Orcas,WPF Designer (Cider)...
# 2

Ok, so I checked out the limitations stuff, but the workaround itslef doesn't compile.

this

xmlns:cider="clr-namespace:SliderAdornerLib;assembly=SliderAdornerLib"

results in this

Error 3 Character ';', hexidecimal value 0x3b is illegal in an XML name.\BindNonText\CSharp\Page1.xaml 5 56 BindNonTextProperty

and this

Error 4 Missing required whitespace. \BindNonText\CSharp\Page1.xaml 5 57 BindNonTextProperty

NIK

NickNotYet at 2007-9-10 > top of Msdn Tech,Visual Studio Orcas,WPF Designer (Cider)...
# 3

I was able to get around the problem by simply specifiying the MyData implementation as belonging to the same namespace as the application.

in MyData.cs

namespace BindNonTextPropertySample

then the sample code compiles just fine, which makes sense.

<DockPanel Name="root"

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

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

xmlns:cider="clr-namespace:BindNonTextPropertySample"

>

<DockPanel.Resources>

<cider:MyData x:Key="myDataSource"/>

</DockPanel.Resources>

<DockPanel DockPanel.Dock="Top" HorizontalAlignment="Left" VerticalAlignment="Top">

<DockPanel.DataContext>

<Binding Source="{StaticResource myDataSource}"/>

</DockPanel.DataContext>

<Button Background="{Binding Path=ColorName}" Width="150" Height="30">I am bound to be RED!</Button>

</DockPanel>

</DockPanel>

NickNotYet at 2007-9-10 > top of Msdn Tech,Visual Studio Orcas,WPF Designer (Cider)...
# 4

Bummer, I still get the error in the designer, which prevents me from doing UI layout visually

:(

Error 7 Assembly '' could not be found. Are you missing an assembly reference? FilterTextForm.xaml 4 13 WPF Spectral Devic


NickNotYet at 2007-9-10 > top of Msdn Tech,Visual Studio Orcas,WPF Designer (Cider)...
# 5

I'm a little confused about what you've tried and not tried with respect to the workaround.

What you need to do in order to get this to work in Cider is:

1) Move any user types (i.e. types you are providing in your code) that you want to reference from XAML in a separate assembly from the XAML files that wish to reference it

2) Build that library assembly

3) In the project that has the XAML files that reference those user defined types, add a file reference (browse to the assembly, do not add a project reference, better yet, don't have the library assembly in your solution -- there are situations where that won't work) to the library assembly.

4) Update the xmlns:cider="clr-namespace:SliderAdornerLib;assembly=SliderAdornerLib" declaration in your file to reference the correct CLR namespace that your types are in and the assembly name of the library assembly.

You should then be able to use your types in the XAML files.

JimNakashima-MSFT at 2007-9-10 > top of Msdn Tech,Visual Studio Orcas,WPF Designer (Cider)...

Visual Studio Orcas

Site Classified