C
Join ServerC#
help
❔ my delegate event is not raising the event
MMorpheus1/20/2023
i defined a event in my CustomerViewModel to pass the data to my main viewModel and raise a new event when gets there. i checked internet for a solution for this to gets working but did not find a answer yet
public partial class CustomerListViewModel : ObservableObject
{
public CustomerListViewModel()
{
customerCollection = new ObservableCollection<Customer>();
Customer jacob = new Customer("Jacob", "Woord", "Urk");
customerCollection.Add(jacob);
}
public event Action<Guid> PlaceOrderRequested = delegate { };
[RelayCommand]
void PlaceOrder(Customer customer)
{
PlaceOrderRequested(customer.CustomerId);
}
namespace viewModelBinding
{
public partial class MainWIndowViewModel : ObservableObject
{
//intialize every vieModel
private CustomerListViewModel customerListViewModel = new CustomerListViewModel();
private OrderListViewModel orderListViewModel = new OrderListViewModel();
private Timer timer = new Timer(5000);
public MainWIndowViewModel()
{
customerListViewModel.PlaceOrderRequested += CustomerListViewModel_PlaceOrderRequested;
currentViewModel = new OrderListViewModel();
timer.Elapsed += (s, e) => NotificationMessage = "Na 5 seconden word de huidige tijd neergzet: " + DateTime.Now.ToLocalTime() + " Kukulukuu";
timer.Start();
}
private void CustomerListViewModel_PlaceOrderRequested(Guid obj)
{
orderListViewModel.CustomerId = obj;
CurrentViewModel = orderListViewModel;
}
[ObservableProperty]
object currentViewModel;
[ObservableProperty]
string notificationMessage;
TTvde11/20/2023
are you sure
PlaceOrder()
is called anywhere?TTvde11/20/2023
Urk btw 😂
MMorpheus1/20/2023
y sure the place order is called in my view and its working, it just never gets to the mainVieModel to get raised. Yes im from Urk 🙂
AAccord1/21/2023
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.