spiegelp / MaterialDesignExtensions

Material Design Extensions is based on Material Design in XAML Toolkit to provide additional controls and features for WPF apps
https://spiegelp.github.io/MaterialDesignExtensions/
MIT License
754 stars 122 forks source link

Side navigation question - Override icon template #113

Closed RobertBeekman closed 3 years ago

RobertBeekman commented 4 years ago

Hello,

This is more of a question than a feature request since I realise this may not be a super broad use-case.

For my application plugins can add items to the menu. However, these plugins are often tied to specific applications/games and therefore the Material Icons usually fall short.

As an alternative plugins may provide a bitmap, since that's what the side navigation supports. However, this means the icon cannot change color, does not adjust to a dark theme etc.

So I'd like to know how you'd recommend to override the icon template with my own SVG-based implementation. Looking at the source it seems I'd need to override this, this and this.

Unfortunately, my WPF knowledge falls short here, so I'm hoping you could give me a suggestion on how to approach this.

Just to avoid any confusion, my question isn't about the SVG implementation, that I'll figure that out myself. It's purely on how to override/expand the data template used for icons

Thanks in advance, and thanks for your work on these extensions!

RobertBeekman commented 3 years ago

I opted to overwrite NavigationItem the datatemplates. A bindable template property would've been nice but I see this won't get a reply.

spiegelp commented 3 years ago

@SpoinkyNL I'm a little bit late, because I was focused on more common features.

The Icon property is of type object. As a possible workaround (not tested yet), you could derive your own class from BitmapImage without implementing any special in it and register a DateTemple for it in App.xaml.

I do not like to remove the default templates. That's why I introduce an optional IconTemplate property on NavigationItem in the next release. There you can register your own DataTemplate for BitmapImage.

RobertBeekman commented 3 years ago

Thank you! I'm sorry that my second message was a bit blunt. Appreciate the effort 👍🏻