using System.Windows.Media; using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.Input; using CommunityToolkit.Mvvm.Messaging; namespace ShrlAlgoToolkit.RevitAddins.Windows { public partial class ColorPickerViewModel : ObservableObject { public ColorPickerViewModel(Color color) { SelectedColor = color; //this.IsActive = true; //WeakReferenceMessenger.Default.Register(this, (r, m) => //{ // // Handle the message here, with r being the recipient and m being the // // input message. Using the recipient passed as input makes it so that // // the lambda expression doesn't capture "this", improving performance. //}); } [ObservableProperty] public partial Color SelectedColor { get; set; } [RelayCommand] private void Confirm(object obj) { if (obj is System.Windows.Window window) { var colorMessage = new Autodesk.Revit.DB.Color( SelectedColor.R, SelectedColor.G, SelectedColor.B ); //发布 window.DialogResult = true; WeakReferenceMessenger.Default.Send(colorMessage); } } } }