diff --git a/src/client/spark/Modules/Trading/AlgoStudio/View/AlgoEditorGridView/AlgoEditorGridView.xaml b/src/client/spark/Modules/Trading/AlgoStudio/View/AlgoEditorGridView/AlgoEditorGridView.xaml
index ce29fd798..cabe66d50 100644
--- a/src/client/spark/Modules/Trading/AlgoStudio/View/AlgoEditorGridView/AlgoEditorGridView.xaml
+++ b/src/client/spark/Modules/Trading/AlgoStudio/View/AlgoEditorGridView/AlgoEditorGridView.xaml
@@ -247,6 +247,31 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -320,6 +345,21 @@
+
+
+
+
+
diff --git a/src/client/spark/view/Controls/Order/AlgoContentTemplateSelector.xaml b/src/client/spark/view/Controls/Order/AlgoContentTemplateSelector.xaml
index 3ab885bde..bd0aad15e 100644
--- a/src/client/spark/view/Controls/Order/AlgoContentTemplateSelector.xaml
+++ b/src/client/spark/view/Controls/Order/AlgoContentTemplateSelector.xaml
@@ -1156,9 +1156,15 @@
diff --git a/src/client/spark/view/Converters/AnonymousValueConverter.cs b/src/client/spark/view/Converters/AnonymousValueConverter.cs
index 29ba7db43..93ce4aa32 100644
--- a/src/client/spark/view/Converters/AnonymousValueConverter.cs
+++ b/src/client/spark/view/Converters/AnonymousValueConverter.cs
@@ -28,9 +28,17 @@ namespace mbts.ui.converters {
IntTextConverter = new IntTextConverter(),
UIntTextConverter = new UIntTextConverter(),
QuantityMeasureTextConverter = ValueConverter.create(fmt),
+ SecuritySelectorText,
SimpleString = new AnonymousValueConverter(obj => obj?.ToString()),
ThicknessToDouble = new ThicknessToDoubleConverter();
+ static ValueConverters() {
+ SecuritySelectorText = new NullSubstitutionConverterWrapper {
+ Converter = SimpleString,
+ ValueForNull = "(None)"
+ };
+ }
+
public static readonly IMultiValueConverter
AreEqualConverter = new AreEqualConverter();
diff --git a/src/client/spark/view/Converters/DictionaryLookupConverter.cs b/src/client/spark/view/Converters/DictionaryLookupConverter.cs
new file mode 100644
index 000000000..cdc635b02
--- /dev/null
+++ b/src/client/spark/view/Converters/DictionaryLookupConverter.cs
@@ -0,0 +1,116 @@
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Linq;
+using System.Windows.Data;
+
+namespace mbts.ui.converters {
+ class DictionaryLookupConverter : IMultiValueConverter {
+ [ThreadStatic]
+ Dictionary _type_impls_backing;
+ Dictionary _type_impls => _type_impls_backing ?? (_type_impls_backing = new Dictionary());
+
+ delegate bool Lookup(object source, object key, out object result);
+
+ public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) {
+ if (values.Length == 2 && values[0] != null && values[1] != null) {
+ var lookup_type = values[0].GetType();
+ var lookup = _type_impls.GetOrAdd(lookup_type, TypeImplResolver.resolve);
+ if (lookup(values[0], values[1], out var result))
+ return result;
+ }
+ return null;
+ }
+
+ public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) =>
+ throw new NotImplementedException();
+
+ static class TypeImplResolver {
+ public static Lookup resolve(Type lookup_type) =>
+ _prioritized_impls(lookup_type)
+ .OrderBy(tup => tup.priority)
+ .Select(tup => tup.impl)
+ .FirstOrDefault() ?? _lookup_fail;
+
+ static bool _lookup_fail(object source, object key, out object result) {
+ result = null;
+ return false;
+ }
+
+ static IEnumerable<(int priority, Lookup impl)> _prioritized_impls(Type lookup_type) {
+ foreach (var itype in lookup_type.GetInterfaces()) {
+ if (itype.IsGenericType) {
+ var gen_def = itype.GetGenericTypeDefinition();
+ if (gen_def == typeof(IDictionary<,>))
+ yield return (1, _get_generic_impl(nameof(_GenericImpls.idictionary), itype));
+ if (gen_def == typeof(IReadOnlyDictionary<,>))
+ yield return (2, _get_generic_impl(nameof(_GenericImpls.ireadonly_dictionary), itype));
+ if (gen_def == typeof(ILookup<,>))
+ yield return (3, _get_generic_impl(nameof(_GenericImpls.ilookup), itype));
+ }
+ if (itype == typeof(IDictionary))
+ yield return (4, _NonGenericImpls.idictionary);
+ }
+ }
+
+ static Lookup _get_generic_impl(string impl_name, Type impl_type) =>
+ _get_generic_impl(impl_name, impl_type.GetGenericArguments());
+
+ static Lookup _get_generic_impl(string impl_name, Type[] key_value_types) =>
+ (Lookup)typeof(_GenericImpls<,>)
+ .MakeGenericType(key_value_types)
+ .GetField(nameof(_GenericImpls.idictionary))
+ .GetValue(null);
+
+ static class _GenericImpls {
+ public static readonly Lookup
+ idictionary = _idictionary,
+ ireadonly_dictionary = _ireadonly_dictionary,
+ ilookup = _ilookup;
+
+ static bool _idictionary(object lookup, object key, out object result) {
+ if (key is TKey k && lookup is IDictionary d && d.TryGetValue(k, out var value)) {
+ result = value;
+ return true;
+ }
+ result = null;
+ return false;
+ }
+
+ static bool _ireadonly_dictionary(object lookup, object key, out object result) {
+ if (key is TKey k && lookup is IReadOnlyDictionary rod && rod.TryGetValue(k, out var value)) {
+ result = value;
+ return true;
+ }
+ result = null;
+ return false;
+ }
+
+ static bool _ilookup(object lookup, object key, out object result) {
+ if ((key is TKey k) && lookup is ILookup l && l.Contains(k)) {
+ result = l[k];
+ return true;
+ }
+ result = null;
+ return false;
+ }
+ }
+
+ static class _NonGenericImpls {
+ public static readonly Lookup
+ idictionary = _idictionary;
+
+ static bool _idictionary(object lookup, object key, out object result) {
+ var dict = (IDictionary)lookup;
+ if (dict.Contains(key)) {
+ result = dict[key];
+ return true;
+ }
+ result = null;
+ return false;
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/client/spark/view/Utility/BindingProxy.cs b/src/client/spark/view/Utility/BindingProxy.cs
new file mode 100644
index 000000000..c00646a04
--- /dev/null
+++ b/src/client/spark/view/Utility/BindingProxy.cs
@@ -0,0 +1,13 @@
+using System.Windows;
+
+namespace mbts.ui {
+ class BindingProxy : FrameworkElement {
+ public static readonly DependencyProperty ValueProperty =
+ DependencyProperty.Register(nameof(Value), typeof(object), typeof(BindingProxy));
+
+ public object Value {
+ get => GetValue(ValueProperty);
+ set => SetValue(ValueProperty, value);
+ }
+ }
+}
\ No newline at end of file