I’ve created a custom control for use in my Silverlight application. Its template is defined in the control library’s Generic.xaml. Is there any way to set properties of the items in that template from the control’s .cs file?
I’ve created a custom control for use in my Silverlight application. Its template is
Share
If you call
GetTemplateChild(string childName)with the name of your element as defined in the XAML, for example:then you can change the properties of the item. You must obviously cast the returned
DependencyObjectto the correct type and check it’s not null – just in case:You need to call this after
OnApplyTemplatehas been called.