I am trying to allow the user to customize the elements in a WPF application. What I am trying to achieve is, if I have a list box which specifies all the form elements (Tex
it worked for me like a charm:
Xaml:
c#:
bool Expanded = false;
// The event subscription method (for a button click)
private void ButtonExpand__Click(object sender, RoutedEventArgs e)
{
Expanded = !Expanded;
Style Style = new Style
{
TargetType = typeof(TreeViewItem)
};
Style.Setters.Add(new Setter(TreeViewItem.IsExpandedProperty, Expanded));
TreePeople.ItemContainerStyle = Style;
}