private void SelectMode(StretchModeItem mode)
 {
     _suspend = true;
     stretchModes.SelectedIndex    = StretchModes.Select(m => m.Tag).IndexOf(mode.Stretch);
     horizontalModes.SelectedIndex = HorizontalAlignments.Select(m => m.Tag).IndexOf(mode.HorizontalAlignment);
     verticalModes.SelectedIndex   = VerticalAlignments.Select(m => m.Tag).IndexOf(mode.VerticalAlignment);
     _suspend = false;
     OnSelectionChanged(null, null);
 }
        private IEnumerable <StretchModeItem> GetAllModes()
        {
            var index = 0;

            foreach (var stretch in StretchModes.Select(m => m.Tag).OfType <Stretch>())
            {
                foreach (var horizontalAlignment in HorizontalAlignments.Select(m => m.Tag).OfType <HorizontalAlignment>())
                {
                    foreach (var verticalAlignment in VerticalAlignments.Select(m => m.Tag).OfType <VerticalAlignment>())
                    {
                        yield return(new StretchModeItem(index++, stretch, horizontalAlignment, verticalAlignment));
                    }
                }
            }
        }