delegate in vb

Topics: Prism v4 - WPF 4
Jan 24, 2014 at 9:15 PM
Hi there,

I have been looking at wpf with prism as I need to expand my knowledge as I'm only doing vb.net window forms.

I have the stock trader demo in vb and I'm getting a error in the
OrdersController. StartOrder(ByVal tickerSymbol As String, ByVal transactionType As TransactionType)

The error is "The region does not contain the specified view."

AddHandler orderCompositeViewModel.CloseViewRequested, Sub()
                                                                   OrderModels.Remove(orderCompositeViewModel)
                                                                   commandProxy.SubmitAllOrdersCommand.UnregisterCommand(orderCompositeViewModel.SubmitCommand)
                                                                   commandProxy.CancelAllOrdersCommand.UnregisterCommand(orderCompositeViewModel.CancelCommand)
                                                                   commandProxy.SubmitOrderCommand.UnregisterCommand(orderCompositeViewModel.SubmitCommand)
                                                                   commandProxy.CancelOrderCommand.UnregisterCommand(orderCompositeViewModel.CancelCommand)
                                                                   ordersRegion.Remove(orderCompositeViewModel) 'errors out on this line
                                                                   If ordersRegion.Views.Count() = 0 Then
                                                                       Me.RemoveOrdersView()
                                                                   End If

                                                               End Sub
ordersRegion.Add(orderCompositeViewModel)
OrderModels.Add(orderCompositeViewModel)

also I need to remove the handler.

Can someone help with this please.

PQSIK
Developer
Jan 31, 2014 at 3:38 PM
Hi,

I have just download the VB version of the Stock Trader RI and could run the StockTraderRI_Desktop solution without any issues.
Have you made any modifications to the solution that could have generated this exception?

Basically, the exception you are recieving appears when you are trying to remove an element from a region but that element is not present in the region's collection.
This problem can appear when:
  • The element was removed from the region before this handler is executed.
  • The element was never injected in the region.
  • The element (in this case the OrderCompositeViewModel) implements the IRegionMemberLifetime interface. In this case, the view should be removed using the Deactivate method instead of the Remove method.
I hope this helps,

Damian Cherubini
http://blogs.southworks.net/dcherubini