MVVM BreadCrump.Path not want to change address or CurrentItem sometimes give me error

4 posts, 0 answers
  1. kity
    kity avatar
    71 posts
    Member since:
    Mar 2012

    Posted 19 Jun 2013 Link to this post

    1. Problem
    If I set Path via mvvm BreadCrump not want to update UI or simple show only root name.

     

    Path="{Binding Path=SelectedTreePath, Mode=TwoWay }"


    <telerik:RadBreadcrumb x:Name="breadcrumbDocumentCategory" 
      
    Header="{Binding PathDocumentsTree}" 
       
    ItemsSource="{Binding Path=PathDocumentsTree.ChildNodes, Mode=TwoWay}" 
      
    PathSeparator="/" TextModePath="Header" 
      
    Path="{Binding Path=SelectedTreePath, Mode=TwoWay }"    
    IsHistoryEnabled="True"
       
      
    <telerik:RadBreadcrumb.HeaderTemplate
       
     
    <DataTemplate
       
      <TextBlock Text="{Binding CategoryName}" /> 
       
    </DataTemplate
       
    </telerik:RadBreadcrumb.HeaderTemplate
      
    <telerik:RadBreadcrumb.ItemTemplate
       
    <telerik:HierarchicalDataTemplate ItemsSource="{Binding ChildNodes}"
      
    <TextBlock Text="{Binding CategoryName}" /> 
       
    </telerik:HierarchicalDataTemplate
      
    </telerik:RadBreadcrumb.ItemTemplate
      
    </telerik:RadBreadcrumb

     

    private
      
       
      
       
      
    string _selectedTreePath; 
       
      
       
      
       
      
    public string SelectedTreePath 
       
      
    {
      
       
      
       
      
    get 
       
      
    {
      
    _recResult = 
      
       
      
    string.Empty; 
       
      
       
      
       
      
    if (this.SelectedTreeNode as CategoryViewModel != null && PathDocumentsTree != null
       
      
    {
      
    _selectedTreePath = ContainerFromItemRecursive(
      
       
      
    this.SelectedTreeNode as CategoryViewModel, PathDocumentsTree.ChildNodes); 
       
      
       
      
    Breadcrumb.Path = _selectedTreePath;
      
    }
      
       
      
       
      
    return _selectedTreePath; 
       
      
    }
      
       
      
       
      
    set { _selectedTreePath = value; RaisePropertyChanged(() => SelectedTreePath); } 
       
      
    }
      
      
      
      
    private
      
       
      
       
      
    string ContainerFromItemRecursive(CategoryViewModel selectedTreeNode, IEnumerable<CategoryTree> documentTree, string path = null
       
      
      
       
      
       
      
    if (documentTree != null
       
      
    {
      
       
      
       
      
    string mp = path; 
       
      
       
      
       
      
    int n = 0; 
       
      
       
      
       
      
    foreach (var item in documentTree) 
       
      
    {
      
    mp = mp + CPathSeparator + item.CategoryName;
      
       
      
       
      
    if (item.CategoryId == selectedTreeNode.ID) 
       
      
    {
      
    path = GetPath(mp, n) + CPathSeparator + item.CategoryName;
      
    _recResult = CRootName + CPathSeparator + path.Replace(
      
       
      
    "//", CPathSeparator); 
       
      
       
      
       
      
    break
       
      
    }
      
       
      
       
      
    else 
       
      
      
    ContainerFromItemRecursive(selectedTreeNode, item.ChildNodes, mp); 
      
    }
      
    n++;
      
    }
      
      
       
      
       
      
    return _recResult.Replace("//", CPathSeparator); 
       
      
    }


    2. Second problem is runtime error if I use CurrentItem to change UI address in RadBreadcrumb (if not appear error it is work correct).

    My be problem is becouse I do not use your recursive travers tree function like ContainerFromItemRecursive()?

    this

     

     

    .explorerBreadcrumb.Path = this.explorerTree.ContainerFromItemRecursive(e.AddedItems[0]).FullPath;

     


    But I thing mine function result is equal to yours?


     I have error in when call RaisePropertyChanged(() => SelectedTreePathItem);

       //Error
       Ambiguous match found.
       {System.Collections.ListDictionaryInternal}

       at System.RuntimeType.GetPropertyImpl(String name, BindingFlags bindingAttr, Binder binder, Type returnType, Type[] types, ParameterModifier[] modifiers)
       at System.Type.GetProperty(String name)
       at Telerik.Windows.Controls.RadBreadcrumb.GetItemChildren(Object currentItem)
       at Telerik.Windows.Controls.RadBreadcrumb.FindCurrentItemRecursively(String currentPath, IEnumerable items, Object searchValue)
       at Telerik.Windows.Controls.RadBreadcrumb.FindCurrentItem(Object newValue)
       at Telerik.Windows.Controls.RadBreadcrumb.OnCurrentItemChanged(Object oldValue, Object newValue)
       at Telerik.Windows.Controls.RadBreadcrumb.OnCurrentItemPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
       at System.Windows.DependencyObject.RaisePropertyChangeNotifications(DependencyProperty dp, Object oldValue, Object newValue)
       at System.Windows.DependencyObject.UpdateEffectiveValue(DependencyProperty property, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, ValueOperation operation)
       at System.Windows.DependencyObject.RefreshExpression(DependencyProperty dp)
       at System.Windows.Data.BindingExpression.SendDataToTarget()
       at System.Windows.Data.BindingExpression.SourcePropertyChanged(PropertyPathListener sender, PropertyPathChangedEventArgs args)
       at System.Windows.PropertyPathListener.ReconnectPath()
       at System.Windows.Data.Debugging.BindingBreakPoint.<>c__DisplayClass4.<BreakOnSharedType>b__3()
      
           
       //my binding property in ViewModel    
       private CategoryTree _selectedTreePathItem;
            public CategoryTree SelectedTreePathItem
            {
                get
                {
                    _recCategoryResult = null;
                    if (this.SelectedTreeNode as CategoryViewModel != null && PathDocumentsTree != null)
                    {
                        _selectedTreePathItem = RecursiveTraverseTreeAndLocateItemById(this.SelectedTreeNode as CategoryViewModel, PathDocumentsTree.ChildNodes);
                        //if (_selectedTreePathItem != null)
                        //    _selectedTreePathItem.ChildNodes.Clear();
                    }
                    return _selectedTreePathItem;
                }
                set { _selectedTreePathItem = value; RaisePropertyChanged(() => SelectedTreePathItem); }
            }
           
           
        // my RadBreadcrumb with CurrentItem
       

    <telerik:RadBreadcrumb Header="{Binding PathDocumentsTree}" 
                                  ItemsSource="{Binding Path=PathDocumentsTree.ChildNodes, Mode=TwoWay}" 
                                    
                                  PathSeparator="/" TextModePath="Header"
                                  CurrentItem="{Binding SelectedTreePathItem, Mode=TwoWay}"
                                  IsHistoryEnabled="True">            
              <telerik:RadBreadcrumb.HeaderTemplate>
                   <DataTemplate>
                       <TextBlock Text="{Binding CategoryName}" />
                   </DataTemplate>
               </telerik:RadBreadcrumb.HeaderTemplate>
               <telerik:RadBreadcrumb.ItemTemplate>
                   <telerik:HierarchicalDataTemplate ItemsSource="{Binding ChildNodes}">                   
                       <TextBlock Text="{Binding CategoryName}" />                    
                   </telerik:HierarchicalDataTemplate>
               </telerik:RadBreadcrumb.ItemTemplate>
           </telerik:RadBreadcrumb>

            
            
            
              // my function that return value

    private CategoryTree _recCategoryResult;
          private CategoryTree RecursiveTraverseTreeAndLocateItemById(CategoryViewModel selectedTreeNode, IEnumerable<CategoryTree> documentTree)
          {                       
              foreach (var item in documentTree)
              {
                  if (item.CategoryId == selectedTreeNode.ID)
                  {
                      _recCategoryResult = item;
                      break;                    
                  }
                  RecursiveTraverseTreeAndLocateItemById(selectedTreeNode, item.ChildNodes);
              }
              return _recCategoryResult;
          }
            
            
          // my models
          public class CategoryTree : FeatureCategoryTreeNode, ICategoryTree, INotifyPropertyChanged
      {                
          private ObservableCollection<CategoryTree> _childNodes;
          public new ObservableCollection<CategoryTree> ChildNodes
          {
              get { return _childNodes; }
              set 
              
                  _childNodes = value;
                  OnPropertyChanged("ChildNodes");
              }
          }
          public CategoryTree(string name)
    {
              this.CategoryName = name;
              this.ChildNodes = new ObservableCollection<CategoryTree>();            
    }
          public CategoryTree(ICategoryTree categoryTree)
          {
              this.CategoryName = categoryTree.CategoryName;
              this.ChildNodes = new ObservableCollection<CategoryTree>();
          }
          public CategoryTree(FeatureCategory featureCategory)
    {
              this.CategoryName = featureCategory.CategoryName;
              this.CategoryId = featureCategory.CategoryId;
              this.ParentId = featureCategory.ParentId;
              this.ChildNodes = new ObservableCollection<CategoryTree>();            
    }
          public CategoryTree(IFeatureCategory featureCategory)
    {
              this.CategoryName = featureCategory.CategoryName;
              this.CategoryId = featureCategory.CategoryId;
              this.ParentId = featureCategory.ParentId;
              this.ChildNodes = new ObservableCollection<CategoryTree>();            
    }
          public CategoryTree()
          {
          }
          public event PropertyChangedEventHandler PropertyChanged;
          public void OnPropertyChanged(string propertyName)
          {
              if (PropertyChanged != null)
                  PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
          }
      }
      public interface ICategoryTree
      {
          string CategoryName { get; set; }
          ObservableCollection<CategoryTree> ChildNodes { get; set; }
           
          Guid CategoryId { get; set; }
          Guid ParentId { get; set; }
      }


    .
           ...

  2. Pavel R. Pavlov
    Admin
    Pavel R. Pavlov avatar
    1182 posts

    Posted 24 Jun 2013 Link to this post

    Hello,

    Can you please take a look at our online demonstration project and see how we implements the behavior that you require. Furthermore, you can find more information about the RadBreadcrumb control in our help documentation.

    On the other hand, I noticed that you’ve been extensively testing our controls for some time now. Would you mind sharing with us what prevents you from purchasing a license. Your feedback would help us determine the show-stoppers that developers like you face and better address them in the future.

    I am looking forward to hearing from you.

    Regards,
    Pavel R. Pavlov
    Telerik

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. DevCraft banner
  4. kity
    kity avatar
    71 posts
    Member since:
    Mar 2012

    Posted 24 Jun 2013 Link to this post

    I notice other strange

    behaviour. Look attached image.

     

  5. Pavel R. Pavlov
    Admin
    Pavel R. Pavlov avatar
    1182 posts

    Posted 27 Jun 2013 Link to this post

    Hi,

    Can you please elaborate more on how you open this "suggest box". If you press the History ToggleButton in the right most of the RadBreadCrumb control - you actually open the history of the control. If you press it when the control is loaded and no browsing history is available - the behavior that you report is expected.

    Regards,
    Pavel R. Pavlov
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
Back to Top