diff --git a/Mystify/Resources/ChannelTemplate.axaml b/Mystify/Resources/ChannelTemplate.axaml
index efdc963..afbdfe1 100644
--- a/Mystify/Resources/ChannelTemplate.axaml
+++ b/Mystify/Resources/ChannelTemplate.axaml
@@ -11,16 +11,26 @@
+
+
+
+
diff --git a/Mystify/ViewModels/ChannelViewModel.cs b/Mystify/ViewModels/ChannelViewModel.cs
index 2dce010..159be1f 100644
--- a/Mystify/ViewModels/ChannelViewModel.cs
+++ b/Mystify/ViewModels/ChannelViewModel.cs
@@ -31,6 +31,9 @@ namespace Mystify.ViewModels
{
if (value != null)
Channel.MapControllable(value.Controllable);
+
+ RaisePropertyChanged(() => Controllable);
+ RaisePropertyChanged(() => IsControllableMapped);
}
}
@@ -40,12 +43,10 @@ namespace Mystify.ViewModels
private async Task SelectControllable()
{
- ControllableSelectionWindow controllableSelectionWindow =
- new()
- {
- DataContext = new ControllableSelectionViewModel(_mainModel.Controllables)
- };
-
+ ControllableSelectionWindow controllableSelectionWindow = new();
+ ControllableSelectionViewModel controllableSelectionViewModel = new(_mainModel.Controllables, controllableSelectionWindow);
+ controllableSelectionWindow.DataContext = controllableSelectionViewModel;
+
Controllable = await controllableSelectionWindow.ShowDialog(_mainWindow);
}
}
diff --git a/Mystify/ViewModels/ControllableSelectionViewModel.cs b/Mystify/ViewModels/ControllableSelectionViewModel.cs
index 8cc613f..49df90c 100644
--- a/Mystify/ViewModels/ControllableSelectionViewModel.cs
+++ b/Mystify/ViewModels/ControllableSelectionViewModel.cs
@@ -6,12 +6,17 @@ using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
+using System.Windows.Input;
using Lib.Audio.Interfaces;
+using Mystify.Views;
+using ReactiveUI;
namespace Mystify.ViewModels
{
public class ControllableSelectionViewModel : ViewModelBase
{
+ private readonly ControllableSelectionWindow? _window;
+
public ControllableSelectionViewModel()
{
if (!IsInDesignMode)
@@ -20,8 +25,10 @@ namespace Mystify.ViewModels
Controllables = new ObservableCollection();
}
- public ControllableSelectionViewModel(List? controllables)
+ public ControllableSelectionViewModel(List? controllables, ControllableSelectionWindow window)
{
+ _window = window;
+
Controllables = controllables == null ? new ObservableCollection() :
controllables.Select(c => new ControllableViewModel(c)).ToObservableCollection();
@@ -30,8 +37,11 @@ namespace Mystify.ViewModels
}
public ObservableCollection Controllables { get; }
- public ControllableViewModel? SelectedControllable { get; private set; }
+ private ControllableViewModel? SelectedControllable { get; set; }
+
+ public ICommand CloseCommand => ReactiveCommand.Create(CloseWindow);
+ private void CloseWindow() => _window?.Close(SelectedControllable);
private void OnControllableSelected(object? sender, bool isSelected)
{
if (!isSelected)
@@ -41,6 +51,7 @@ namespace Mystify.ViewModels
return;
SelectedControllable = controllableViewModel;
+ CloseWindow();
}
}
}
\ No newline at end of file
diff --git a/Mystify/Views/ControllableSelectionWindow.axaml b/Mystify/Views/ControllableSelectionWindow.axaml
index 6b8111c..e4db66a 100644
--- a/Mystify/Views/ControllableSelectionWindow.axaml
+++ b/Mystify/Views/ControllableSelectionWindow.axaml
@@ -14,6 +14,10 @@
+
+
+
+