Files
bluflame/intromat/Intromat/Views/GroupNodeView.xaml.cs
2026-04-18 22:31:51 +02:00

38 lines
1.2 KiB
C#

using System.Reactive.Disposables;
using System.Windows;
using Intromat.ViewModels.Nodes;
using ReactiveUI;
namespace Intromat.Views
{
public partial class GroupNodeView : IViewFor<GroupNodeViewModel>
{
public static readonly DependencyProperty ViewModelProperty = DependencyProperty.Register(nameof(ViewModel),
typeof(GroupNodeViewModel), typeof(GroupNodeView), new PropertyMetadata(null));
public GroupNodeView()
{
InitializeComponent();
this.WhenActivated(d =>
{
NodeView.ViewModel = ViewModel;
Disposable.Create(() => NodeView.ViewModel = null).DisposeWith(d);
this.OneWayBind(ViewModel, vm => vm.NodeType, v => v.NodeView.Background, CodeGenNodeView.ConvertNodeTypeToBrush).DisposeWith(d);
});
}
public GroupNodeViewModel? ViewModel
{
get => (GroupNodeViewModel?)GetValue(ViewModelProperty);
set => SetValue(ViewModelProperty, value);
}
object? IViewFor.ViewModel
{
get => ViewModel;
set => ViewModel = (GroupNodeViewModel?)value;
}
}
}