Laservall_solidworks_inject/Common/ComboxPropertyEditor.cs

31 lines
875 B
C#

using HandyControl.Controls;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
namespace Laservall.Solidworks.Common
{
public class ComboxPropertyEditor : PropertyEditorBase
{
public override FrameworkElement CreateElement(PropertyItem propertyItem)
{
var comboBox = new ComboBox();
comboBox.ItemsSource = new List<string> { "A", "B", "C" };
comboBox.SelectedItem = propertyItem.Value?.ToString();
comboBox.SelectionChanged += (s, e) =>
{
propertyItem.Value = comboBox.SelectedItem;
};
return comboBox;
}
public override DependencyProperty GetDependencyProperty()
{
return ComboBox.SelectedItemProperty;
}
}
}