public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value as OptionsField == null) return null;

            _optionsField = (OptionsField)value;
            return _optionsField.Options.FirstOrDefault(o => o.IsChecked);
        }
        /// <summary>
        /// Get a static IEnumerable of Options from the OptionsString and Value
        /// </summary>
        private static IEnumerable<Option> GetOptions(string optionsString, string value, OptionsField parent)
        {
            if (String.IsNullOrEmpty(optionsString))
            {
                return new List<Option>();
            }

            var names = optionsString.Split(',').Select(CsvWriter.Unescape).ToList();

            var options = names.Select((t, i) => new Option { Name = t, Parent = parent }).ToArray();

            if (!String.IsNullOrEmpty(value))
            {
                var selectedIndexes = value.Split(',').Select(CsvWriter.Unescape).Select(int.Parse);
                foreach (var index in selectedIndexes)
                    options.ElementAt(index).IsChecked = true;
            }

            return options;
        }
 //private so it is not automatically called
 private void DeleteOptionsField(OptionsField optionsField)
 {
     this.ObjectContext.DetachExistingAndAttach(optionsField);
     this.ObjectContext.Fields.DeleteObject(optionsField);
 }
 /// <summary>
 /// Create a new OptionsField object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="name">Initial value of the Name property.</param>
 /// <param name="required">Initial value of the Required property.</param>
 /// <param name="createdDate">Initial value of the CreatedDate property.</param>
 /// <param name="allowMultipleSelection">Initial value of the AllowMultipleSelection property.</param>
 /// <param name="typeInt">Initial value of the TypeInt property.</param>
 public static OptionsField CreateOptionsField(global::System.Guid id, global::System.String name, global::System.Boolean required, global::System.DateTime createdDate, global::System.Boolean allowMultipleSelection, global::System.Int16 typeInt)
 {
     OptionsField optionsField = new OptionsField();
     optionsField.Id = id;
     optionsField.Name = name;
     optionsField.Required = required;
     optionsField.CreatedDate = createdDate;
     optionsField.AllowMultipleSelection = allowMultipleSelection;
     optionsField.TypeInt = typeInt;
     return optionsField;
 }