/// <summary> /// Register a forwarding listener to another bindable /// </summary> /// <param name="originalDispatcher">The bindable to forward from</param> public void ForwardOnChange(IBindable originalDispatcher) { if (!ForwardedBindables.ContainsKey(originalDispatcher)) { // create an anonymous function the is used for forwarding var forwarding = (BindableCallback)((c, o) => Dispatch(o)); // add it and dont immediatly dispatch originalDispatcher.OnChange(forwarding, false); // remember the anonymous function ForwardedBindables[originalDispatcher] = forwarding; } }
protected virtual void BindData <T>(IBindable <T> bindable, BindableCallback listener) { // remember the listener so it can be removed on destruction of the mediator RegisteredDataBindings.Add( new KeyValuePair <IBindable, BindableCallback>( bindable, listener ) ); // apply the listener bindable.OnChange(listener); }