For most of the day I changed class bindings to use DataContext = this in the constructor or FindAncestor calls at the binding declaration. Late in the day I ran into an infinite recursion problem. Not wanting to diagnose it I found an MSDN article pointing me to use RegisterName("Window", this); in the constructor after InitializeComponent() to work around the issue.
Wednesday, February 4, 2009
Binding to XAML declared types with non-default constructors using ElementName binding syntax
Some of our XAML files were using Element name binding like this Binding="{Binding ElementName=Window}" to bind to the class itself. While refactoring and adding a non default constructor Visual Studio complains: "The type CLASSNAME cannot have a Name attribute. Value types and types without a default constructor can be used as items within a ResourceDictionary."
Subscribe to:
Post Comments (Atom)
4 comments:
Thanks so much! This worked pretty well and your post saved me some time investigating on this issue :-)
Amiable post and this enter helped me alot in my college assignement. Gratefulness you seeking your information.
Thanks. In the same boat with refactoring some views to common base classes I was stuck with this error. This was an easy way to fix it.
Nice brief and this fill someone in on helped me alot in my college assignement. Gratefulness you on your information.
Post a Comment