TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Eduardo Fernandes
NA
1
8.1k
XamlObjectWriter fails with bindings?
Oct 6 2010 5:50 AM
Hi All.
I'm Trying to load the following basic xaml with XamlObjectWriter (.Net 4) (source code included)
<Window
xmlns="
http://schemas.microsoft.com/winfx/2006/xaml/presentation
"
xmlns:x="
http://schemas.microsoft.com/winfx/2006/xaml
"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
Title="MainWindow" Height="350" Width="525" x:Name="mainWindow">
<Grid>
<TextBox Name="myTextBox" Height="23" HorizontalAlignment="Left" Margin="271,71,0,0" VerticalAlignment="Top" Width="120" />
<Button Content="{Binding ElementName=myTextBox, Path=Text}" Width="100" Margin="97,4,306,0"/>
</Grid>
</Window>
The code is quite simple:
XmlReader xr = XmlReader.Create("../../XAMLSimpl.xaml");
XamlXmlReader reader = new XamlXmlReader(xr);
XamlObjectWriter writer = new XamlObjectWriter(reader.SchemaContext);
while (reader.Read())
{
writer.WriteNode(reader);
}
object res = writer.Result;
When I run the the code I get the following exception (because the binding)
{"A 'Binding' cannot be set on the 'Content' property of type 'Button'. A 'Binding' can only be set on a DependencyProperty of a DependencyObject."}
A 'Binding' cannot be set on the 'Content' property of type 'Button'. A 'Binding' can only be set on a DependencyProperty of a DependencyObject.
If I try to use the old style code:
FileStream reader = new FileStream("../../XAMLSimpl.xaml", FileMode.Open);
object res = System.Windows.Markup.XamlReader.Load(reader);
Everything works fine.
Any suggestion?
Many thanks in advance,
Edu.
Attachment:
XamlError.zip
Reply
Answers (
0
)
What is HTTPModule and HttpHandler ?
Uploading a file from a web form and putting into a database field using ODBC