diff --git a/Filtration/Filtration.csproj b/Filtration/Filtration.csproj
index 9412cf2..31dd393 100644
--- a/Filtration/Filtration.csproj
+++ b/Filtration/Filtration.csproj
@@ -172,6 +172,7 @@
BlockItemControl.xaml
+
EditableListBoxControl.xaml
diff --git a/Filtration/UserControls/DesignTime/DesignTimeEditableListBoxControl.cs b/Filtration/UserControls/DesignTime/DesignTimeEditableListBoxControl.cs
new file mode 100644
index 0000000..bc91488
--- /dev/null
+++ b/Filtration/UserControls/DesignTime/DesignTimeEditableListBoxControl.cs
@@ -0,0 +1,28 @@
+using System.Collections.Generic;
+using GalaSoft.MvvmLight.CommandWpf;
+
+namespace Filtration.UserControls.DesignTime
+{
+ internal class DesignTimeEditableListBoxControl : IEditableListBoxControl
+ {
+ public RelayCommand AddItemCommand { get; }
+ public RelayCommand DeleteItemCommand { get; }
+ public IEnumerable AutoCompleteItemsSource { get; set; }
+ ICollection IEditableListBoxControl.ItemsSource { get; set; }
+
+ public string Label
+ {
+ get { return "Base Types"; }
+ set { }
+ }
+
+ public string AddItemText { get; set; }
+
+ public ICollection ItemsSource
+ {
+ get { return new List {"Test Item 1", "Blah", "Another Item"}; }
+ }
+
+ public string SelectedItem { get { return "Blah"; } }
+ }
+}
\ No newline at end of file
diff --git a/Filtration/UserControls/EditableListBoxControl.xaml b/Filtration/UserControls/EditableListBoxControl.xaml
index 67ad475..ec548ac 100644
--- a/Filtration/UserControls/EditableListBoxControl.xaml
+++ b/Filtration/UserControls/EditableListBoxControl.xaml
@@ -5,10 +5,11 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:userControls="clr-namespace:Filtration.UserControls"
xmlns:toolkit="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Input.Toolkit"
+ xmlns:designTime="clr-namespace:Filtration.UserControls.DesignTime"
mc:Ignorable="d"
- d:DataContext="{d:DesignInstance Type=userControls:EditableListBoxControl}">
+ d:DataContext="{d:DesignInstance Type=designTime:DesignTimeEditableListBoxControl, IsDesignTimeCreatable=True}">
-
+
@@ -21,8 +22,11 @@
Grid.Column="0"
Grid.ColumnSpan="2"
ItemsSource="{Binding ItemsSource}"
+ SelectedItem="{Binding SelectedItem}"
BorderThickness="1"
Height="120"
+ HorizontalContentAlignment="Stretch"
+ ScrollViewer.HorizontalScrollBarVisibility="Disabled"
VerticalAlignment="Stretch" SelectionMode="Single" x:Name="ControlListBox" BorderBrush="#CCCCCC">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Filtration/UserControls/EditableListBoxControl.xaml.cs b/Filtration/UserControls/EditableListBoxControl.xaml.cs
index b83a939..1ac06f7 100644
--- a/Filtration/UserControls/EditableListBoxControl.xaml.cs
+++ b/Filtration/UserControls/EditableListBoxControl.xaml.cs
@@ -2,14 +2,22 @@
using System.ComponentModel;
using System.Runtime.CompilerServices;
using System.Windows;
-using System.Windows.Controls;
using System.Windows.Input;
using Filtration.Annotations;
using GalaSoft.MvvmLight.CommandWpf;
namespace Filtration.UserControls
{
- public partial class EditableListBoxControl : INotifyPropertyChanged
+ public interface IEditableListBoxControl
+ {
+ RelayCommand AddItemCommand { get; }
+ RelayCommand DeleteItemCommand { get; }
+ IEnumerable AutoCompleteItemsSource { get; set; }
+ ICollection ItemsSource { get; set; }
+ string AddItemText { get; set; }
+ }
+
+ public partial class EditableListBoxControl : INotifyPropertyChanged, IEditableListBoxControl
{
private string _addItemText;
@@ -23,8 +31,8 @@ namespace Filtration.UserControls
DeleteItemCommand = new RelayCommand(OnDeleteItemCommand);
}
- public RelayCommand AddItemCommand { get; private set; }
- public RelayCommand DeleteItemCommand { get; private set; }
+ public RelayCommand AddItemCommand { get; }
+ public RelayCommand DeleteItemCommand { get; }
public static readonly DependencyProperty ItemsSourceProperty = DependencyProperty.Register(
"ItemsSource",
@@ -33,13 +41,6 @@ namespace Filtration.UserControls
new FrameworkPropertyMetadata(OnItemsSourcePropertyChanged)
);
- public static readonly DependencyProperty LabelProperty = DependencyProperty.Register(
- "Label",
- typeof (string),
- typeof (EditableListBoxControl),
- new FrameworkPropertyMetadata()
- );
-
public static readonly DependencyProperty AutoCompleteItemsSourceProperty = DependencyProperty.Register(
"AutoCompleteItemsSource",
typeof (IEnumerable),
@@ -59,12 +60,6 @@ namespace Filtration.UserControls
set { SetValue(ItemsSourceProperty, value); }
}
- public string Label
- {
- get { return (string)GetValue(LabelProperty); }
- set { SetValue(LabelProperty, value); }
- }
-
public string AddItemText
{
get { return _addItemText; }
@@ -100,6 +95,14 @@ namespace Filtration.UserControls
control?.OnPropertyChanged(nameof(ItemsSource));
}
+ private void AutoCompleteBox_OnPreviewKeyDown(object sender, KeyEventArgs e)
+ {
+ if (e.Key == Key.Enter)
+ {
+ AddItemCommand.Execute(null);
+ }
+ }
+
public event PropertyChangedEventHandler PropertyChanged;
[NotifyPropertyChangedInvocator]
@@ -108,13 +111,5 @@ namespace Filtration.UserControls
var handler = PropertyChanged;
handler?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
-
- private void AutoCompleteBox_OnPreviewKeyDown(object sender, KeyEventArgs e)
- {
- if (e.Key == Key.Enter)
- {
- AddItemCommand.Execute(null);
- }
- }
}
}