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

Binding The Path Property and Delayed Binding

3 Answers 225 Views
BreadCrumb
This is a migrated thread and some comments may be shown as answers.
Voltz
Top achievements
Rank 1
Voltz asked on 26 Aug 2011, 09:42 AM
Hi,

we're testing the breadcrumb control right now and would like to bind the Path property instead of using code behind (since we're using MVVM) however, even if that property already uses notify property changed, the breadcrumb is still not updating the path.

aside from this, we have several tree views and would like to update the itemsource for the control, but it isn't reflecting in the control as expected (a second click would reflect the new itemssource.
the data is okay if we

private ObservableCollection<TreeViewItems> items;
public ObservableCollection<TreeViewItems> Items
{
    get
    {
        return items;
    }
    set
    {
        items = value;
        OnPropertyChanged("Items");
    }
}
 
private string currentPath = "";
public string CurrentPath
{
    get
    {
        return currentPath;
    }
    set
    {
        currentPath = value;
        OnPropertyChanged("CurrentPath");
    }
}

internal void OnSelectedMenuChanged(TreeViewItems tvi)
        {
            ...some code...
 
            this.R = Util.CreateTreeView();
            //returns an observable collection similar to the sample implementation
            this.CurrentPath = sb.ToString();
 
        }

<telerik:RadBreadcrumb x:Name="explorerBreadcrumb"
     Path="{Binding CurrentPath}"
     Header="{Binding R[0]}"
     HeaderMemberPath="CategoryName"
     HierarchicalItemsSource="SubCategories"
     HierarchicalMemberPath="CategoryName"
     ItemsSource="{Binding R[0].SubCategories}"
     TextModePath="CategoryName" />


thanks!

3 Answers, 1 is accepted

Sort by
0
Zarko
Telerik team
answered on 31 Aug 2011, 01:27 PM
Hello Voltz,
Thank you for the feedback. We are aware of the problem with the Path property when you bind it and you can track the progress of this issue here (we'll try to fix this for the Q2 2011 SP).
As for the dynamic change of the RadTreeView collection - I couldn't reproduce this issue so I'd like to ask you for more information on this topic.
For further information could you please examine the attached project and if you have more questions feel free to ask.

Kind regards,
Zarko
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

0
Voltz
Top achievements
Rank 1
answered on 07 Sep 2011, 03:21 AM
Hi, i've examined the code and made adjustments.

what we were looking into is changing the itemssource of the the breadcrumb control at runtime.

say in your example we have Items, and another ObservableCollection Items2, then at any event, or invocation, the breadcrumb can switch its itemssource from Items to Items2.

    private ObservableCollection<TreeViewItem> items;
    private ObservableCollection<TreeViewItem> items2;
    private string currentPath = "";
 
public MainViewModel()
{
    this.items = new ObservableCollection<TreeViewItem>();
    for (int i = 0; i < 4; i++)
    {
        var item = new TreeViewItem() { Header = i.ToString() };
        for (int j = 0; j < 3; j++)
        {
            item.Children.Add(new TreeViewItem() { Header = i + "." + j });
        }
        this.items.Add(item);
    }
        this.items2 = new ObservableCollection<TreeViewItem>();
       for (int i = 0; i < 4; i++)
       {
           var item = new TreeViewItem() { Header = i.ToString() };
           for (int j = 0; j < 3; j++)
           {
               item.Children.Add(new TreeViewItem() { Header = i + ".aaa" + j });
           }
           this.items2.Add(item);
       }
}
    public ObservableCollection<TreeViewItem> Items
    {
        get
        {
            return items;
        }
        set
        {
            items = value;
            OnPropertyChanged("Items");
        }
    }
 
    public ObservableCollection<TreeViewItem> Items2
    {
        get
        {
            return items2;
        }
        set
        {
            items2 = value;
            OnPropertyChanged("Items2");
        }
    }
let's say this is your viewmodel,

and in your xaml you add a new button and call this...

private void Button_Click_2(object sender, RoutedEventArgs e)
{
    explorerBreadcrumb.ItemsSource = this.mvm.Items2;
}

what we were expecting if for the breadcrumb to change its contents.

Thanks for your help!
0
Accepted
Zarko
Telerik team
answered on 07 Sep 2011, 10:27 AM
Hello Voltz,
I'm glad to tell you that this issue is already fixed and the fix will be available in the Q2 2011 SP (later this month). For now I can give a workaround - after you change the ItemsSource you have to change/refresh the Header too like this:
this.explorerBreadcrumb.ItemsSource = this.mvm.Items2;
this.explorerBreadcrumb.Header = "Root";
and everything should work fine.
I've updated the attached project and if you have more questions feel free to ask.


All the best,
Zarko
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

Tags
BreadCrumb
Asked by
Voltz
Top achievements
Rank 1
Answers by
Zarko
Telerik team
Voltz
Top achievements
Rank 1
Share this question
or