We need to assign the Name property at the runtime using the data binding. We have the control template defined and WPF doesn’t allow to bind the name from the the Data Bind object.
If I do, I get error like,
Error 3 MarkupExtensions are not
allowed for Uid or Name property
values, so ‘{Binding Name}’ is not
valid. Line 15 Position
36. C:\Users\gsubramani\Workspace\ProLinkIII_Experiment\BasicFrame\Resources\TreeTemplate.xaml 15 36 BasicFrame
To work around, Is it possible to define a custom property which intern set the Name property of the control through data binding?
I don’t know how to the handle the DependencyProperty in WPF so that I can define a custom property that intern set the Name property of the control? ( I am very new to WPF world).
You would need to define an attached dependency as per the documentation here:
http://msdn.microsoft.com/en-us/library/cc903943%28VS.95%29.aspx
Then provide a method which is invoked when this property changes. You can do this by adding another argument to the propertyMetdata, that points to a static method:
In this handler, d, is the object that the property has been attached to, and e.NewValue will contain the name.
However, I think it is a little odd that you want to bind the Name of your elements. Can you please share why you want to do this?
Regards, Colin E.