I have a composite WPF application. I plan to implement toolbar functionality. There are several elements of the toolbar (mainly printing, saving, hiding, expanding, undoing) that will be distributed to all types in the main region. To do this, I created a default toolbar module that will add these elements (print, save, hide, expand, cancel) to the toolbar area. when the user clicks on any element of the toolbar, this should be handled by all 20 views in the main area.
For each toolbar item, I have associated a prism delegate object.
:
private ICommand _printCommand; public ICommand PrintCommand { get { if (_printCommand == null) { _printCommand = new DelegateCommand<object>(**Print**, **CanPrint**); } return _printCommand; } }
Xaml, bind a toolbar item to this command.
20 . . , .
: , print , . 20 .
?
. , , .
: 40 → 20 , , baseviewmodel.
→ → compositesaveallcommand ( ) baseviewmodel → save → / compositesaveallcommand
, compositesaveallcommand viewmodel ( canexecute true), ( execute).
, , 19 . . , comamnds, .
, , , . Save All Save, . , RTS Stock Trader Submit Cancel / SubmitAllOrders CancelAllOrders, (. OrdersController).
commandProxy.SubmitAllOrdersCommand.RegisterCommand( orderCompositeViewModel.SubmitCommand ); commandProxy.CancelAllOrdersCommand.RegisterCommand( orderCompositeViewModel.CancelCommand );
commandProxy , . . StockTraderRICommands.cs.
public class MyViewModel : NotificationObject { private readonly CompositeCommand saveAllCommand; public ArticleViewModel(INewsFeedService newsFeedService, IRegionManager regionManager, IEventAggregator eventAggregator) { this.saveAllCommand = new CompositeCommand(); this.saveAllCommand.RegisterCommand(new SaveProductsCommand()); this.saveAllCommand.RegisterCommand(new SaveOrdersCommand()); } public ICommand SaveAllCommand { get { return this.saveAllCommand; } } }
, CompositeCommand. , (Commanding QuickStart RI , Prism v1), , , . , , IsActive, , ( , ).
EventAggregator . , , , , .
EventAggregator, , , , . , ... , Prism , , , .
CompositeCommands . , , EventAggregator? , ViewModels , , , ? , / , , ..
CompositeCommand Prism , , .
Source: https://habr.com/ru/post/1732407/More articles:How to check ASP pages on local Mac OS X? - testingHow to use "SelectMany" with DataServiceQuery <> - odataHow to create a number of polygons using a metapost? - layoutКак переопределить имя элемента xml для элементов коллекции с помощью XmlAttributeOverrides? - overrideLink_to_remote with nested routes - ruby-on-railsEclipse CDT - Copy static resource file to bin_dir - eclipseIs dealloc called after viewDidUnload? - objective-chttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1732410/rails-with-models-a-hasmany-b-belongsto-c-return-a-where-b-belongs-to-c-and-b-is-most-recently-created-for-given-a&usg=ALkJrhjSv3U51bPYP-nbLcoMhcEgLis-cgAccess Violation Exception When Calling a Method - c ++ASP.NET Code Coverage - vb.netAll Articles