Hi,
I want to determine the selection of ItemTemplateSelector depending on a property of my user control.
I have a property:
private static string _showItemEditOptions;
public string ShowItemEditOptions
{
get { return _showItemEditOptions; }
set { _showItemEditOptions = value; }
}
That is set in xaml:
<local:CodesTreeControl x:Name="codesTreeControl" ShowItemEditOptions="False"></local:CodesTreeControl>
I then want to determine the ItemTemplateSelector I use based on the value of this control:
if (ShowItemEditOptions == "False")
{
TreeView.ItemTemplateSelector = this.Resources["myReadOnlyTemplateSelector"] as ReadOnlyTemplateSelector;
}
else
{
TreeView.ItemTemplateSelector = this.Resources["myAttributeCodingTemplateSelector"] as AttributeCodingTemplateSelector;
}
So far so good. I can change the ItemTemplateSelector based on the value of a variable. Unfortunately, I can't access my property immediately after InitializeComponent(); as it hasn't had time to load. If I leave it any later than this, then the treeview has intialised itself and it's too late to set the ItemTemplateSelector.
Is there a TreeView event I can access to set the ItemTemplateSelector in time?
Thanks, James.
I want to determine the selection of ItemTemplateSelector depending on a property of my user control.
I have a property:
private static string _showItemEditOptions;
public string ShowItemEditOptions
{
get { return _showItemEditOptions; }
set { _showItemEditOptions = value; }
}
That is set in xaml:
<local:CodesTreeControl x:Name="codesTreeControl" ShowItemEditOptions="False"></local:CodesTreeControl>
I then want to determine the ItemTemplateSelector I use based on the value of this control:
if (ShowItemEditOptions == "False")
{
TreeView.ItemTemplateSelector = this.Resources["myReadOnlyTemplateSelector"] as ReadOnlyTemplateSelector;
}
else
{
TreeView.ItemTemplateSelector = this.Resources["myAttributeCodingTemplateSelector"] as AttributeCodingTemplateSelector;
}
So far so good. I can change the ItemTemplateSelector based on the value of a variable. Unfortunately, I can't access my property immediately after InitializeComponent(); as it hasn't had time to load. If I leave it any later than this, then the treeview has intialised itself and it's too late to set the ItemTemplateSelector.
Is there a TreeView event I can access to set the ItemTemplateSelector in time?
Thanks, James.