This is a migrated thread and some comments may be shown as answers.

IsExpandableBinding not removing the expander icon

1 Answer 61 Views
TreeListView
This is a migrated thread and some comments may be shown as answers.
Teddy
Top achievements
Rank 1
Teddy asked on 12 Mar 2013, 06:14 PM
I've set up an object with IsExpandable and IsExpanded properties.  I've found that when I set the IsExpandable property to false, the expander icon does not go away, as expected.

Here's my code for the Model:
public partial class Tag
{
    private bool _isExpanded;
    private bool _isExpandable;
    private ObservableCollection<Tag> _children;
 
    public string TagID { get; set; }
    public string TagName { get; set; }
 
    public bool IsExpanded
    {
        get { return _isExpanded; }
        set
        {
            if (_isExpanded != value)
            {
                _isExpanded = value;
                RaisePropertyChanged("IsExpanded");
            }
        }
    }
 
    public bool IsExpandable
    {
        get { return _isExpandable; }
        set
        {
            if (_isExpandable != value)
            {
                _isExpandable = value;
                RaisePropertyChanged("IsExpandable");
            }
        }
    }
 
    public ObservableCollection<Tag> Children
    {
        get { return _children; }
        set
        {
            _children = value;
            RaisePropertyChanged("Children");
        }
    }
}

And here's the xaml for the tree list view:
<telerik:RadTreeListView ItemsSource="{Binding TopLevelTags}"
               IsExpandedBinding="{Binding IsExpanded, Mode=TwoWay}"
               IsExpandableBinding="{Binding IsExpandable}"
               CanUserFreezeColumns="False"
               CanUserReorderColumns="False"
               CanUserSortColumns="False">
    <telerik:RadTreeListView.ChildTableDefinitions>
        <telerik:TreeListViewTableDefinition ItemsSource="{Binding Children}" />
    </telerik:RadTreeListView.ChildTableDefinitions>
    <telerik:RadTreeListView.Columns>
        <telerik:GridViewDataColumn Header="TagID"
                         DataMemberBinding="{Binding TagID}"
                         TextAlignment="Left"
                         ShowDistinctFilters="False"
                         IsReadOnly="True" />
        <telerik:GridViewDataColumn Header="TagName"
                         DataMemberBinding="{Binding TagName, Mode=TwoWay}"
                         TextAlignment="Left"
                         ShowDistinctFilters="False"
                         IsReadOnly="False" />
    </telerik:RadTreeListView.Columns>
</telerik:RadTreeListView>

In my View Model, I listen to the property changed event for each item, and if the IsExpanded flag has been set, I get the data from the database and add it to the Children collection. Here's the code for that:
private async void OnTagPropertyChanged(object sender, PropertyChangedEventArgs e)
{
    if (e.PropertyName == "IsExpanded")
    {
        Tag tag = sender as Tag;
 
        if (tag == null) { return; }
 
        if (tag.IsExpanded && (tag.Children == null || !tag.Children.Any()))
        {
            IEnumerable<Tag> childTags = await Context.LoadAsync(Context.GetChildTagsQuery(tag.TagPK));
 
            if (childTags.Any())
            {
                tag.Children = new ObservableCollection<Tag>();
                foreach (Tag t in childTags)
                {
                    t.IsExpandable = true;
                    t.IsExpanded = false;
 
                    t.PropertyChanged += OnTagPropertyChanged;
 
                    tag.Children.Add(t);
                }
            }
            else
            {
                tag.IsExpandable = false;
            }
        }
    }
}

My problem is that when I set tag.IsExpandable = false, the expander icon does not disappear as expected.  But, if I collapse and re-expand the item's parent, the expander will then be gone, as expected.  This seems like a bug to me, as I am raising a notify property changed event, but the change isn't happening right away.

P.S. With this example, if I click the left arrow on some items, an exception is thrown.  If this ends up being a bug you add to PITS, can you also add the left arrow issue as well?

P.P.S.  I'm running Q1 2013.

1 Answer, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 13 Mar 2013, 07:54 AM
Hi,

 Please open support ticket and send us an example project demonstrating the problem. We will review your implementation and we will post more info about our findings. 

All the best,
Vlad
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
TreeListView
Asked by
Teddy
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Share this question
or