Closed AlexDialga closed 1 year ago
Describe the bug I created a ConnectorViewModel with ContextMenu, and try to bind to ContextMenu of nodify:NodeInput in EditorView, but it can't be open.
To Reproduce
EditorView.xaml
<!--...--> <nodify:Node.InputConnectorTemplate> <DataTemplate DataType="{x:Type localConnectors:IConnectorViewModel`1}"> <nodify:NodeInput ... ContextMenu="{Binding ConnectorContextMenu}" ... > <!--...-->
ConnectorViewModel.cs
using System.Windows.Controls using CommunityToolkit.Mvvm.ComponentModel; public interface IConnectorViewModel : IObservableObject { //... ContextMenu? ConnectorContextMenu { get; set; } //... } public class ConnectorViewModel : ObservableRecipient, IConnectorViewModel { //... protected ContextMenu? connectorContextMenu = new(); public virtual ContextMenu? ConnectorContextMenu { get => this.connectorContextMenu; set => SetProperty(ref this.connectorContextMenu, value); } protected ObservableCollection<object> connectorContextMenuItems = new ObservableCollection<object>(); public virtual ObservableCollection<object> ConnectorContextMenuItems { get => this.connectorContextMenuItems; set => SetProperty(ref this.connectorContextMenuItems, value); } //... public ConnectorViewModel() { var menuItem = new MenuItem() { Header = "TheMenuItem", Name = "TheMenuItem" }; this.ConnectorContextMenuItems.Add(menuItem); this.ConnectorContextMenu = new() { ItemsSource = this.ConnectorContextMenuItems }; } //... } public interface IConnectorViewModel<T> : IConnectorViewModel { //... } public class ConnectorViewModel<T> : ConnectorViewModel , IConnectorViewModel<T> { //... }
Expected behavior You can create a NodeViewModel and add a ContextMenu and a ContextMenuItems, and bind to the nodify:Node in EditorView.
Hi, thanks for reporting the bug! I published the fix. Can you please update to the latest version and try again?
Amazing! Now connectors can add different context menu now!
Describe the bug I created a ConnectorViewModel with ContextMenu, and try to bind to ContextMenu of nodify:NodeInput in EditorView, but it can't be open.
To Reproduce
EditorView.xaml
ConnectorViewModel.cs
Expected behavior You can create a NodeViewModel and add a ContextMenu and a ContextMenuItems, and bind to the nodify:Node in EditorView.