Cannot bind Icon property in NavigationView MenuItemTemplate

前端 未结 2 484
挽巷
挽巷 2021-01-03 08:21

I\'ve tried to use a NavigationView because it looks very useful, but I\'m struggling to make it work with the MVVM pattern.

I\'ve attached the MenuItem

2条回答
  •  青春惊慌失措
    2021-01-03 08:38

    You state that you dont want to manually add the icon as part of the MenuItemTemplate because it's not the way it's thought to be (which is absolutely correct), yet you actually do the exact same thing for setting the menu item's text (manually adding a TextBlock instead of setting the menu item's Content property).

    The TextBlock overrides any NavigationItemView that is automatically created, so there is no icon element to be displayed (a TextBlock only contains text, no icon).

    Try to simply use a NavigationViewItem as template:

    
        
            
                
            
        
    
    

提交回复
热议问题