The goal is to hide/show a window from the task tray using Hardcoded WPF NotifyTrayIcon
in a MVVM solution. The problem is the CommandParameter
always seems to be null, which then of course cause the code to crash. I've tried a number of different bindings including:
CommandParameter="{Binding Mode=OneWay, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:MainWindow}}}"
CommandParameter="{Binding ElementName=window, Mode=OneWay}"
etc but everything passes back a null, any suggestions?
Thanks
If you have only one Window then you could simply use Application.Current.MainWindow
.
If you have more then you may search for the good one in the Application.Current.Windows
collection.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.