You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am creating an UI Builder for Blazor and in order to update Blazor when changes occur to the backing ViewModel. In particular, I would like to use the property 'Position' changes within the ComponentViewModel base class. The Position property is updated via a separate Drag/Drop service.
I have an interface for ComponentViewModel called IComponentViewModel which is how I've defined my backing DD SourceList.
private SourceList<IComponentViewModel> _componentViewModelSourceList = new SourceList<IComponentViewModel>();
private ReadOnlyObservableCollection<IComponentViewModel>? _childComponents;
public CompositeDisposable? Disposables { get; set; }
public IObservable<Position> NewPosition { get; }
Within the constructor I am binding the SourceList to a ReadOnlyObservableCollection 'ChildComponents' as follows, which works great!
Also within the constructor I am attempting to AutoRefresh on changes to the 'Position' property within IComponentViewModel as follows...
var NewPosition = _componentViewModelSourceList.Connect()
// Subscribe to changes on Position property.
.AutoRefresh(x => x.Position)
.Select();
however I receive the following error.
CS0311: The type '...IComponentViewModel' cannot be used as a type parameter 'TObject' in the generic method 'IObservableListEx.AutoRefresh<TObject, TProperty> ...'
If I change the SourceList to be the ComponentViewModel then the error goes away, however I would prefer (if possible) to keep it as IComponentViewModel.
Is there some way to add an operator to cast the IObservablable ChangeSet so that I can apply the AutoRefresh with the interface approach.
Thank you in advance.
The text was updated successfully, but these errors were encountered:
Yes, ideally, but so far it may not be needed as in my current design, each specialized ComponentViewModel does not currently have any additional properties that I would need to apply AutoRefresh, but may in the future, so it would be ideal if I could AutoRefresh on any property within either ComponentViewModel as well as any property in the SpecializedComponentViewModel.
At a very high-level, this is the relationship.
Specialized1ComponentViewModel which inherits from ComponentViewModel ==> Binds to Specialized1BlazorViewComponent
..
SpecializedXComponentViewModel which inherits from ComponentViewModel ==> Binds to SpecializedXBlazorViewComponent
The actual Blazor component's Type information is held within the SpecializedComponentViewModel, which is how different components are rendered within the Designer Canvas.
I am creating an UI Builder for Blazor and in order to update Blazor when changes occur to the backing ViewModel. In particular, I would like to use the property 'Position' changes within the ComponentViewModel base class. The Position property is updated via a separate Drag/Drop service.
I have an interface for ComponentViewModel called IComponentViewModel which is how I've defined my backing DD SourceList.
Within the constructor I am binding the SourceList to a ReadOnlyObservableCollection 'ChildComponents' as follows, which works great!
Also within the constructor I am attempting to AutoRefresh on changes to the 'Position' property within IComponentViewModel as follows...
however I receive the following error.
CS0311: The type '...IComponentViewModel' cannot be used as a type parameter 'TObject' in the generic method 'IObservableListEx.AutoRefresh<TObject, TProperty> ...'
If I change the SourceList to be the ComponentViewModel then the error goes away, however I would prefer (if possible) to keep it as IComponentViewModel.
Is there some way to add an operator to cast the IObservablable ChangeSet so that I can apply the AutoRefresh with the interface approach.
Thank you in advance.
The text was updated successfully, but these errors were encountered: