problems with Wpf syntax

G

Guest

Below is code derived from a Msdn example. The error is in the line
"<c:MyData x:Key="myDataSource"/>" at the point c:MyData. Vs2005 complains
that this is not an allowed element in that part of the Xaml. Everything else
appears to be acceptable. The SDKSample namespace is in a separate C# Dll
module called "SDKSample.dll". It is included in the Reference section of the
Wpf project. The class MyData is public and has a default constructor. The
string property is publc.

I can't find references to the specific XmlNamespace:Class usage in Msdn.

Could someone indicate what I am doing wrong?

Thanks.

<Window x:Class="Wpf6.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Canvas Sample" Width="400" Height="400"
Name="mainWindow"
<DockPanel
xmlns:c="clr-namespace:SDKSample;assembly=SDKSample"
<DockPanel.Resources>
<c:MyData x:Key="myDataSource"/>
</DockPanel.Resources>
<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>
</Window>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top