Traverse window using CommandParameter from ContextMenu

The goal is to hide / show the window from the task tray using Hardcoded WPF NotifyTrayIcon

in an MVVM solution. The problem is it CommandParameter

always appears to be null, which of course causes the code to fail. I have tried several different bindings including:

CommandParameter="{Binding Mode=OneWay, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:MainWindow}}}"

CommandParameter="{Binding ElementName=window, Mode=OneWay}"

      

and so on but everything returns zero, any suggestions?

thank

+3


source to share


1 answer


If you only have one window, you can just use Application.Current.MainWindow

.



If you have more, you can find a good one in the collection Application.Current.Windows

.

0


source







All Articles