port from perforce
This commit is contained in:
34
intromat/Intromat/Views/Editors/EnumEditorView.cs
Normal file
34
intromat/Intromat/Views/Editors/EnumEditorView.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
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))!;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user