I set up a very simple demo.

 

I did everything inside a Window and it (the binding) worked fine.

 

I moved all the logic to a usercontrol and used that usercontrol in my
window and it did not work.

 

Ok. I thought I was onto to something.

 

I very carefully reversed everything and it worked.

 

I commented out the logic in my window and reference my usercontrol again
and tested it again.

It worked !!!!!

 

Thought there was a name conflict as my UserControl had a Name attribute but
when I referenced it in my main window I used a x:Name attribute.

 

Tested it again, still works!!!!!

 

If I had any hair to spare, I would be pulling it out.

 

Not a good Friday.

 

I think I will simplify everything to the real basics and then add an test
as I go.

 

Regards Peter

 

 

 

From: [email protected] [mailto:[email protected]] On
Behalf Of Stephen Price
Sent: Friday, 4 March 2011 2:17 PM
To: ozWPF
Subject: Re: Adding ListBoxItems to a listbox programmatically

 

Have a look in your output window for binding exceptions. You can also turn
on Common Language Runtime Exceptions (check Thrown to stop on all
exceptions) Debug -> Exceptions (or Ctrl-D,E). That sometimes helps you with
incorrect XAML. 

 

One comment, I can't see how your object you are binding to is getting into
your DataContext from your code example. Set a breakpoint somewhere and
check your UserControl's datacontext has something in it to bind to.

 

cheers,

Stephen

_______________________________________________
ozwpf mailing list
[email protected]
http://prdlxvm0001.codify.net/mailman/listinfo/ozwpf

Reply via email to