I'm using a ControlTemplate to add a couple of additional Controls (an Image and a TextBlock) to RadTreeViewItem. I'm also using a HierarchicalDataTemplate and data binding to attach the RadTreeView to my data.
With this, I'm unable to find any way to bind these additional controls to data, or access the additional controls in code. If I were creating the TreeViewItems myself, I think I'd create a subclass of RadTreeViewItem and add a couple of properties that I could bind the new controls to.
What I ended up doing was add the following to RadTreeViewItem:
This allows me to find my child controls in code when the RadTreeViewItem is loaded and then bind my data to them.
Is there a better way to do this?
Is it possible to get the RadTreeView to create my sub-classed RadTreeViewItem, rather than a RadTreeViewItem? It looks like it isn't, but if there's no better way to do this, would it be worth adding?
With this, I'm unable to find any way to bind these additional controls to data, or access the additional controls in code. If I were creating the TreeViewItems myself, I think I'd create a subclass of RadTreeViewItem and add a couple of properties that I could bind the new controls to.
What I ended up doing was add the following to RadTreeViewItem:
/// <summary>
/// Exposes protected GetTemplateChild
/// </summary>
public
DependencyObject PublicGetTemplateChild(
string
childName)
{
//
// In the base control class GetTemplateChild is protected. I need to open it up for
// RadTreeViewItem so we can find elements that we added in data templates
//
return
GetTemplateChild(childName);
}
This allows me to find my child controls in code when the RadTreeViewItem is loaded and then bind my data to them.
Is there a better way to do this?
Is it possible to get the RadTreeView to create my sub-classed RadTreeViewItem, rather than a RadTreeViewItem? It looks like it isn't, but if there's no better way to do this, would it be worth adding?