Hi Im writing a WPF application that has user login. I use Modern UI for this application. The application has following LinkGroups:
<mui:ModernWindow.MenuLinkGroups>
<mui:LinkGroup DisplayName="Group 1">
<mui:LinkGroup.Links>
<mui:Link DisplayName="A" Source="/Pages/A.xaml" />
<mui:Link DisplayName="B" Source="/Pages/B.xaml" />
<mui:Link DisplayName="C" Source="/Pages/C.xaml" />
</mui:LinkGroup.Links>
</mui:LinkGroup>
<mui:LinkGroup DisplayName="Group 2">
<mui:LinkGroup.Links>
<mui:Link DisplayName="D" Source="/Pages/D.xaml" />
<mui:Link DisplayName="F" Source="/Pages/F.xaml" />
<mui:Link DisplayName="G" Source="/Pages/G.xaml" />
</mui:LinkGroup.Links>
</mui:LinkGroup>
</mui:ModernWindow.MenuLinkGroups>
I want to hide or disable Link group named "Group 2" depending on user ID. Is there a way to do it?
Maybe it is too late, but I think that had a solution.
Since LinkGroup
is not derived from UIElement
it is not possible to hide it, but you can work around this. I'm sure that it isn't the clearest solution, but it worked for me.
You can reach your LinkGroup
s via
var window = App.Current.MainWindow as ModernWindow;
var toRemove = window.MenuLinkGroups.ElementAt(1);
MenuLinkGroups
is a Collection<T>
thus you can Add
and Remove
items.
window.MenuLinkGroups.Remove(toRemove);
You can also generate a LinkGroupCollection
after login and bind ModernWindow.MenuLinkGroups
to this collection.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With