Hi how do i use a delegatecommand in a treeview to get the expanded event Should i be using the delegatecommnd or is there another way.
thanks
Hi how do i use a delegatecommand in a treeview to get the expanded event Should i be using the delegatecommnd or is there another way.
thanks
Since you are mentioning Prism, I assume you have a controller or ViewModel attached to the view containing your TreeView...
That being the case, expose a boolean property IsExpanded
private bool _isExpanded;
public bool IsExpanded
{
get { return _isExpanded; }
set
{
if (value != _isExpanded)
{
_isExpanded = value;
RaisePropertyChanged("IsExpanded");
// Apply custom logic here...
}
}
}
Now to hook this property up to the TreeView, you need to apply the following style in the TreeView's resources (or further up the Visual tree as appropriate)
<Style TargetType="{x:Type TreeViewItem}">
<Setter Property="IsExpanded" Value="{Binding Path=IsExpanded, Mode=TwoWay}" />
</Style>
NB: You can also use a similar technique to hook up the IsSelected property - also very useful!!