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.
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
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> 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
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.