private void OnBeginTransaction(object sender, ExecutedRoutedEventArgs e)
        {
            ModelPropertyEntryBase property = GetContainedPropertyFromEventArgs(e);

            if (property == null)
            {
                return;
            }

            _pendingTransactions.Add(property.BeginEdit(e.Parameter as string));
        }
コード例 #2
0
        // Converts an instance of PropertyValue to its appropriate display name
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (typeof(string).IsAssignableFrom(targetType))
            {
                PropertyValue propertyValue = value as PropertyValue;
                if (propertyValue != null)
                {
                    ModelPropertyEntryBase propertyEntry = propertyValue.ParentProperty as ModelPropertyEntryBase;

                    // Figure out the value type name
                    string valueTypeName = string.Empty;
                    if (propertyEntry != null)
                    {
                        valueTypeName = propertyEntry.CommonValueType == null ? string.Empty : propertyEntry.CommonValueType.Name;
                    }
                    else
                    {
                        Debug.Fail("PropertyValueToDisplayNameConverter is being used for something other than ModelPropertyValues.  Re-evaluate the correctness of its logic.");

                        // Fallback mechanism
                        object rawPropertyValue = propertyValue.Value;
                        if (rawPropertyValue != null)
                        {
                            valueTypeName = rawPropertyValue.GetType().Name;
                        }
                    }

                    // See if there is a regular name
                    string propertyName = ModelUtilities.GetPropertyName(propertyValue);

                    if (string.IsNullOrEmpty(propertyName))
                    {
                        // Type only
                        return(string.Format(
                                   culture,
                                   Resources.PropertyEditing_CollectionItemDisplayFormatType,
                                   valueTypeName));
                    }
                    else
                    {
                        // Type and name
                        return(string.Format(
                                   culture,
                                   Resources.PropertyEditing_CollectionItemDisplayFormatTypeAndName,
                                   valueTypeName,
                                   propertyName));
                    }
                }
            }

            return(string.Empty);
        }
コード例 #3
0
        // IValueConverter Members

        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            Fx.Assert(typeof(IEnumerable).IsAssignableFrom(targetType), "Expecting IEnumerable as the targetType");

            PropertyValue propertyValue = value as PropertyValue;

            if (propertyValue == null)
            {
                return(null);
            }

            ModelPropertyEntryBase parentProperty = (ModelPropertyEntryBase)propertyValue.ParentProperty;

            return(new ConvertedStandardValuesCollection(parentProperty, culture));
        }
コード例 #4
0
 internal ConvertedStandardValuesCollection(ModelPropertyEntryBase property, CultureInfo culture)
 {
     _property = property;
     _culture  = culture;
 }