eventaggregator

WPF PRISM event subcriptions not dying

妖精的绣舞 提交于 2019-12-14 02:15:12
问题 I have a PRISM RegionManager with a couple of region - a Ribbon region on the top, and a main content region for my view underneath it - fairly basic. The app starts with a "home" view in the main content area. When I click a button on the Ribbon, I inject a second view into the content area and navigate to it in the region manager. When I click a button on this view, it should be removed and the original view should be shown. I'm currently doing this using the RegionManager.Add() method to

View, ViewModel and DataContext

那年仲夏 提交于 2019-12-13 21:41:04
问题 In order to solve a navigation issue in my application I have used an Event Aggregator which has solved the problem but has created an other one. To navigate between different UserControls I used the Rachel's code you can find here which was working fine until I made some changes. On the side of my screen I have a Main Menu ( HomeViewModel() ), by clicking on the items I switch between UserControls and in each of these UserControls there is a another menu bar where I can switch between other

Navigate between UserControls with Event Aggegator

两盒软妹~` 提交于 2019-12-13 18:31:42
问题 I have a MainWindow where I navigate between UserControls by clicking on a menu and it works fine. I am using this following pattern: https://rachel53461.wordpress.com/2011/05/08/simplemvvmexample/ In one of those usercontrol there is a button. By clicking on this button I want to navigate to another usercontrol. How do I do that? MainView <UserControl.Resources> <DataTemplate DataType="{x:Type cvm:FirstViewModel}"> <cv:FirstView/> </DataTemplate> <DataTemplate DataType="{x:Type cvm

What is the best method to load Views dynamically from a Navigation control in Prism

大城市里の小女人 提交于 2019-12-13 16:14:58
问题 I've implemented navigation through my application using a Menu control which publish an event using EventAggregator on click of menu item. Something like as shown below, this.eventAggregator.GetEvent<ViewRequestedEvent>() .Publish(new BusinessObject.Model.MenuModel { Module = "Dashboard", PresenterClass = "DashboardViewModel" }); Most of the Modules in my application are subscriber to this event. They use a filter to subscribe only those events relevant to the Module this.eventAggregator

How to verify the EventAggregator's unsubscribe method is called when disposing a ViewModel with Prism

萝らか妹 提交于 2019-12-11 16:14:57
问题 I'm struggling to write a test that confirms that I am correctly unsubscribing from an EventAggregator's message when it is closed. Anyone able to point out the (simple) answer?! Here is the code: public class ViewModel : BaseViewModel, IViewModel { private readonly IEventAggregator eventAggregator; private SubscriptionToken token; IssuerSelectedEvent issuerSelectedEvent; public ViewModel(IView view, IEventAggregator eventAggregator) { this.eventAggregator = eventAggregator; View = view;

Why does my Moq IEventAggregator verification fail?

旧城冷巷雨未停 提交于 2019-12-11 09:26:34
问题 I use Composite WPF(Prism) and I am trying to unit test that my Controller does in fact subscribe to a Composite Event. My subscription code looks as follows... //Init Events. this.eventAggregator.GetEvent<PlantTreeNodeSelectedEvent>().Subscribe( ShowNodeDetails, ThreadOption.UIThread); My unit testing code looks as follows (I use Moq as my Mocking Framework and Unity as my DI Framework)... Mock<PlantTreeNodeSelectedEvent> eventBeingListenedTo = new Mock<PlantTreeNodeSelectedEvent>();

How ISubject and Subject will look like in this sample and are the sample using them in the right place?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-11 07:23:38
问题 I got this sample http://jfromaniello.blogspot.com/2010/04/event-aggregator-with-reactive.html, Which describe event aggregator pattern using .net 4.0 but i didn't find in the sample code the ISubject interface and the Subject class and i found the he is using them in the EventAggregator class, is it right to use them like that and what will their code will look like? 回答1: I'm not 100% sure what you are asking here - are you just looking for the ISubject interface and implementation? If so

GetEvent<SetObjectEvent> could not be found (missing directive/reference?) - what am I doing wrong ..?

 ̄綄美尐妖づ 提交于 2019-12-11 04:15:32
问题 While trying to build an eventaggregator to have the properties of my object be transfered from MainViewModel to SectionViewModel I've tried following multiple articles (1, 2, 3 and 4 ) as to how this works, but I seem to be missing a step..? In the MainViewModel I have; protected readonly IEventAggregator eventAggregator; public MainViewModel(IMainViewModel mainViewModel, IEventAggregator eventAggregator) { ...Some other Code... this.eventAggregator = eventAggegator; } public Object Object {

Mixing enums with event classes in an event aggregator

◇◆丶佛笑我妖孽 提交于 2019-12-10 19:43:40
问题 I attempted to implement my own simple event aggregator recently. I got a lot of inspiration from the event aggregator article on MSDN. There is one thing that I notice about the event aggregator on MSDN is the events are actually classes on their own. This isn't really a bad thing at all. However, I just find it awkward to always create a new empty class for every single little event. The reason I find it awkward is because of the need to create a class for every single granular event. A

Composite WPF EventAggregator subscriptions being lost

送分小仙女□ 提交于 2019-12-10 15:57:28
问题 In my Composite WPF application I have an event that is published when the user double-clicks on a control. Modules subscribe to the event and perform an action when necessary. This event seems to stop working at random. Sometimes when I run the application I can trigger the event with no problems, other times I can only trigger it a few times before the modules stop receiving the event. When I look in the debugger the CAL EventAggregator still has the event, but the event has no