Compound wpf prism team

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 .

?

+3
4

. , , .

: 40 → 20 , , baseviewmodel.

→ → compositesaveallcommand ( ) baseviewmodel → save → / compositesaveallcommand

, compositesaveallcommand viewmodel ( canexecute true), ( execute).

, , 19 . . , comamnds, .

+2

, , , . 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; }
    }
}
+2

, CompositeCommand. , (Commanding QuickStart RI , Prism v1), , , . , , IsActive, , ( , ).

+1

EventAggregator . , , , , .

EventAggregator, , , , . , ... , Prism , , , .

CompositeCommands . , , EventAggregator? , ViewModels , , , ? , / , , ..

CompositeCommand Prism , , .

0

Source: https://habr.com/ru/post/1732407/


All Articles