MVVM Dynamic Menu UI from binding with ViewModel

前端 未结 5 1256
南方客
南方客 2020-11-29 00:53

I am working with a team on LoB application. We would like to have a dynamic Menu control, which creates the menu based on the logged in user profile. In previo

5条回答
  •  误落风尘
    2020-11-29 01:36

    Try something like this:

    public class MenuItemViewModel
    {
        public MenuItemViewModel()
        {
            this.MenuItems = new List();
        }
    
        public string Text { get; set; }
    
        public IList MenuItems { get; private set; }
    }
    

    Assume that your DataContext has a property called MenuItems which is a list of MenuItemViewModel. Something like this should work, then:

    
        
            
                
            
        
        
            
            
        
    
    

提交回复
热议问题