diff --git a/src/MahApps.Metro/Controls/MultiSelectionComboBox/MultiSelectionComboBox.cs b/src/MahApps.Metro/Controls/MultiSelectionComboBox/MultiSelectionComboBox.cs
index ceb867ed8a..3c988dad22 100644
--- a/src/MahApps.Metro/Controls/MultiSelectionComboBox/MultiSelectionComboBox.cs
+++ b/src/MahApps.Metro/Controls/MultiSelectionComboBox/MultiSelectionComboBox.cs
@@ -138,40 +138,47 @@ private static bool IsValidSelectionMode(object o)
|| value == SelectionMode.Extended;
}
- /// Identifies the dependency property.
- public static readonly DependencyProperty SelectedItemsProperty =
- DependencyProperty.Register(
+
+ internal static readonly DependencyPropertyKey SelectedItemsPropertyKey =
+ DependencyProperty.RegisterReadOnly(
nameof(SelectedItems),
typeof(IList),
typeof(MultiSelectionComboBox),
new PropertyMetadata((IList)null));
+ /// Identifies the dependency property.
+ public static readonly DependencyProperty SelectedItemsProperty = SelectedItemsPropertyKey.DependencyProperty;
+
+
///
/// The currently selected items.
///
[Bindable(true), Category("Appearance"), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public IList SelectedItems
{
- get
- {
- return PART_PopupListBox?.SelectedItems;
- }
+ get { return (IList)GetValue(SelectedItemsProperty); }
+ protected set { SetValue(SelectedItemsPropertyKey, value); }
}
- /// Identifies the dependency property.
- public static readonly DependencyProperty DisplaySelectedItemsProperty =
- DependencyProperty.Register(
+
+
+ internal static readonly DependencyPropertyKey DisplaySelectedItemsPropertyKey =
+ DependencyProperty.RegisterReadOnly(
nameof(DisplaySelectedItems),
typeof(IEnumerable),
typeof(MultiSelectionComboBox),
new PropertyMetadata((IEnumerable)null));
+ /// Identifies the dependency property.
+ public static readonly DependencyProperty DisplaySelectedItemsProperty = DisplaySelectedItemsPropertyKey.DependencyProperty;
+
///
/// Gets the in the specified order which was set via
///
public IEnumerable DisplaySelectedItems
{
get { return (IEnumerable)GetValue(DisplaySelectedItemsProperty); }
+ protected set { SetValue(DisplaySelectedItemsPropertyKey, value); }
}
/// Identifies the dependency property.
@@ -246,20 +253,25 @@ public string Separator
set { SetValue(SeparatorProperty, value); }
}
- /// Identifies the dependency property.
- public static readonly DependencyProperty HasCustomTextProperty =
- DependencyProperty.Register(
+
+ internal static readonly DependencyPropertyKey HasCustomTextPropertyKey =
+ DependencyProperty.RegisterReadOnly(
nameof(HasCustomText),
typeof(bool),
typeof(MultiSelectionComboBox),
new PropertyMetadata(false));
+
+ /// Identifies the dependency property.
+ public static readonly DependencyProperty HasCustomTextProperty = HasCustomTextPropertyKey.DependencyProperty;
+
///
/// Indicates if the text is userdefined
///
public bool HasCustomText
{
get { return (bool)GetValue(HasCustomTextProperty); }
+ protected set { SetValue(HasCustomTextPropertyKey, BooleanBoxes.Box(value)); }
}
/// Identifies the dependency property.
@@ -351,7 +363,7 @@ public IParseStringToObject StringToObjectParser
///
public void ResetEditableText()
{
- SetCurrentValue(HasCustomTextProperty, BooleanBoxes.FalseBox);
+ HasCustomText = false;
UpdateEditableText();
}
@@ -580,18 +592,18 @@ private void UpdateHasCustomText(string selectedItemsText)
bool hasCustomText = !((string.IsNullOrEmpty(selectedItemsText) && string.IsNullOrEmpty(Text)) || string.Equals(Text, selectedItemsText, EditableTextStringComparision));
- SetCurrentValue(HasCustomTextProperty, BooleanBoxes.Box(hasCustomText));
+ HasCustomText = hasCustomText;
}
private void UpdateDisplaySelectedItems(OrderSelectedItemsBy orderBy)
{
if (orderBy == OrderSelectedItemsBy.SelectedOrder)
{
- SetCurrentValue(DisplaySelectedItemsProperty, SelectedItems);
+ DisplaySelectedItems = SelectedItems;
}
else if (orderBy == OrderSelectedItemsBy.ItemsSourceOrder)
{
- SetCurrentValue(DisplaySelectedItemsProperty, ((IEnumerable