34 lines
999 B
C#
34 lines
999 B
C#
using System;
|
|
using System.Reactive.Disposables;
|
|
using System.Windows;
|
|
using System.Windows.Controls;
|
|
using Intromat.ViewModels.Editors;
|
|
using ReactiveUI;
|
|
|
|
namespace Intromat.Views.Editors
|
|
{
|
|
[TemplatePart(Name = nameof(_comboBoxValue), Type = typeof(ComboBox))]
|
|
public class EnumEditorView : EditorViewBase<EnumEditorViewModel>
|
|
{
|
|
private ComboBox _comboBoxValue = null!;
|
|
|
|
public EnumEditorView()
|
|
{
|
|
DefaultStyleKey = typeof(EnumEditorView);
|
|
|
|
this.WhenActivated(d =>
|
|
{
|
|
foreach (var name in Enum.GetNames(ViewModel!.EnumType))
|
|
_comboBoxValue.Items.Add(name);
|
|
|
|
this.OneWayBind(ViewModel, vm => vm.Value, v => v._comboBoxValue.SelectedIndex).DisposeWith(d);
|
|
});
|
|
}
|
|
|
|
public override void OnApplyTemplate()
|
|
{
|
|
base.OnApplyTemplate();
|
|
_comboBoxValue = (ComboBox)GetTemplateChild(nameof(_comboBoxValue))!;
|
|
}
|
|
}
|
|
} |