-
- christyjquinn
- Posts: 17
- Joined:
Binding dependency property to another user control isn't binding
Hello,
Hitting a bit of a strange issue with dependency properties and user controls.
I have a user control where a string is passed in as a dependency property:
Inside that user control it calls another user control passing that same dependency property value down:
This doesn't work and just appears to do nothing. But if I bind that same property to the TextBlock control it displays that value:
If I assign the value directly to the nested user control it also works:
Any ideas/tips would be much appreciated!
Hitting a bit of a strange issue with dependency properties and user controls.
I have a user control where a string is passed in as a dependency property:
Code: Select all
<components:FullscreenModalComponent ImagesDir="/Images/collections_jpg" />
Code: Select all
<components:ResponsiveImageComponent ImagesDir="{Binding ElementName=Root, Path=ImagesDir}" />
Code: Select all
<TextBlock Text="{Binding ElementName=Root, Path=ImagesDir}" />
Code: Select all
<components:ResponsiveImageComponent ImagesDir="/Images/collections_jpg" />
-
-
sfernandez
Site Admin
- Posts: 2783
- Joined:
Re: Binding dependency property to another user control isn't binding
Hi,
I've been able to reproduce this problem. It turns out that the binding in the inner user control is resolved against its own namescope, and because its name is also "Root", it is binding to its own property value, which is empty by default.
You can workaround the problem now by just naming each user control root differently.
Anyway, could you please report it in our bugtracker so we can fix it?
I've been able to reproduce this problem. It turns out that the binding in the inner user control is resolved against its own namescope, and because its name is also "Root", it is binding to its own property value, which is empty by default.
You can workaround the problem now by just naming each user control root differently.
Anyway, could you please report it in our bugtracker so we can fix it?
-
- christyjquinn
- Posts: 17
- Joined:
Re: Binding dependency property to another user control isn't binding
Awesome thanks for the tip and great catch! Will report in the bugtracker now.
-
-
sfernandez
Site Admin
- Posts: 2783
- Joined:
Re: Binding dependency property to another user control isn't binding
Thanks for the report!
Who is online
Users browsing this forum: Ahrefs [Bot] and 3 guests