private void UpdateSummary(IList newValue)
{
const string space = " ";
string summary = null;
if (null != SummaryForSelectedItemsDelegate)
{
// Ask the delegate to sumarize the selected items.
summary = SummaryForSelectedItemsDelegate(newValue);
}
if (summary == null)
{
// No summary was provided, so by default, show only the first item in the selection list.
if (null == newValue || newValue.Count == 0)
{
// In the case that there were no selected items, show the empty string.
summary = space;
}
else
{
summary = newValue[0].ToString();
}
}
// The display does not size correctly if the empty string is used.
if (String.IsNullOrEmpty(summary))
{
summary = space;
}
if (summary == space && SelectedItem != null)
{
summary = SelectedItem.ToString();
}
if (null != _multipleSelectionModeSummary)
{
_multipleSelectionModeSummary.Text = summary;
if (_multipleSelectionModeSummary.Visibility == System.Windows.Visibility.Collapsed)
{
_multipleSelectionModeSummary.Visibility = System.Windows.Visibility.Visible;
}
}
}