protected DataGridItemProperty(DataGridItemProperty template) : base(template) { // this.IsAutoCreated = false, after a clone, we consider the ItemProperty not AutoCreated. m_propertyDescriptor = template.m_propertyDescriptor; m_valueXPath = template.m_valueXPath; m_valuePath = template.m_valuePath; }
/// <summary> /// Builds collection of dynamic custom oreder properties fields /// </summary> /// <returns></returns> private Collection<DataGridItemProperty> _GetDynamicCustomOrderProperties(string baseValuePath, bool isReadOnly) { Collection<DataGridItemProperty> dynamicProperties = new Collection<DataGridItemProperty>(); OrderCustomPropertiesInfo infos = App.Current.Project.OrderCustomPropertiesInfo; for (int i = 0; i < infos.Count; i++) { string valuePath = baseValuePath + string.Format("CustomProperties[{0}]", i); string valueName = OrderCustomProperties.GetCustomPropertyName(i); Type type = (infos[i].Type == OrderCustomPropertyType.Text)? typeof(string) : typeof(double); DataGridItemProperty newProperty = new DataGridItemProperty(valueName, valuePath, type); newProperty.IsReadOnly = isReadOnly; dynamicProperties.Add(newProperty); } return dynamicProperties; }
/// <summary> /// Builds collection of dynamic capacities /// </summary> /// <returns></returns> private Collection<DataGridItemProperty> _GetDynamicCapacitiesProperties(string baseValuePath, bool isReadonly) { Collection<DataGridItemProperty> dynamicProperties = new Collection<DataGridItemProperty>(); for (int i = 0; i < App.Current.Project.CapacitiesInfo.Count; i++) { string valuePath = baseValuePath + string.Format("Capacities[{0}]", i); string valueName = Capacities.GetCapacityPropertyName(i); DataGridItemProperty newProperty = new DataGridItemProperty(valueName, valuePath, typeof(double)); newProperty.IsReadOnly = isReadonly; dynamicProperties.Add(newProperty); } return dynamicProperties; }
/// <summary> /// Builds collection of dynamic address fields /// </summary> /// <returns></returns> private Collection<DataGridItemProperty> _GetDynamicAddressProperties(string baseValuePath, bool isReadOnly) { Collection<DataGridItemProperty> dynamicProperties = new Collection<DataGridItemProperty>(); AddressField[] addressFields = App.Current.Geocoder.AddressFields; for (int i = 0; i < addressFields.Length; i++) { if (addressFields[i].Visible) { string valuePath = baseValuePath + string.Format("Address[{0}]", addressFields[i].Type.ToString()); string propertyName = addressFields[i].Type.ToString(); DataGridItemProperty newProperty = new DataGridItemProperty(propertyName, valuePath, typeof(string)); newProperty.IsReadOnly = isReadOnly; dynamicProperties.Add(newProperty); } } return dynamicProperties; }
private List<DataGridItemPropertyBase> CreateItemPropertiesForTable() { DataTable modelDataTable = ( m_dataTable != null ) ? m_dataTable : m_modelSource as DataTable; Debug.Assert( modelDataTable != null, "This method should not have been called in the first place if both m_dataTable and m_sourceSchema are null." ); DataColumnCollection columns = modelDataTable.Columns; int columnCount = columns.Count; List<DataGridItemPropertyBase> properties = new List<DataGridItemPropertyBase>( columnCount ); for( int i = 0; i < columnCount; i++ ) { DataColumn column = columns[ i ]; DataGridItemProperty property = new DataGridItemProperty( new DataRowColumnPropertyDescriptor( column ), true ); property.Title = column.Caption; properties.Add( property ); } return properties; }
protected DataGridItemProperty( DataGridItemProperty template ) : base( template ) { // this.IsAutoCreated = false, after a clone, we consider the ItemProperty not AutoCreated. m_propertyDescriptor = template.m_propertyDescriptor; m_valueXPath = template.m_valueXPath; m_valuePath = template.m_valuePath; }
internal override void SetUnspecifiedPropertiesValues(DataGridItemPropertyCollection itemPropertyCollection) { // ContainingCollection.ItemType and ContainingCollection.DefaultItemProperties can be null at first when this is // the ItemProperties of a DetailGrid. // the SetUnspecifiedPropertiesValues will be recall when both this.ItemType and this.DefaultItemProperties are affected. if (itemPropertyCollection == null) { return; } DataGridItemProperty defaultItemProperty = null; bool itemIsXceedDataRow = (itemPropertyCollection.ItemType != null) ? typeof(DataRow).IsAssignableFrom(itemPropertyCollection.ItemType) : false; if ((string.IsNullOrEmpty(this.ValueXPath)) && (string.IsNullOrEmpty(this.ValuePath)) && (this.PropertyDescriptor == null)) { if (itemIsXceedDataRow) { this.PropertyDescriptor = new UnboundDataRowPropertyDescriptor(this.Name, this.DataType); } else { defaultItemProperty = itemPropertyCollection.FindDefaultItemProperty(this.Name) as DataGridItemProperty; if (defaultItemProperty == null) { if (this.Name == ".") { this.SetPropertyDescriptor(new SelfPropertyDescriptor(this.DataType)); this.SetValuePath("."); this.SetIsReadOnly(true); this.SetOverrideReadOnlyForInsertion(false); } else if (itemPropertyCollection.DefaultItemProperties != null) { // I have to add this particular exception case to make sure that when the ItemProperty is "re-normalized" when the first DataGridCollectionView // is created for it, then the ValuePath is still null or empty (allowing it to be re-normalized) this.SetValuePath(this.Name); } } else { this.SetPropertyDescriptor(defaultItemProperty.PropertyDescriptor); this.SetValuePath(defaultItemProperty.ValuePath); this.SetValueXPath(defaultItemProperty.ValueXPath); } } } if (this.DataType == null) { //only try to affect the DataType if the DefaultItemProperties were set. (will not be the case when XAML parsing DetailDescriptions) if (itemPropertyCollection.DefaultItemProperties != null) { if (defaultItemProperty == null) { defaultItemProperty = itemPropertyCollection.FindDefaultItemProperty(this.Name) as DataGridItemProperty; } if (defaultItemProperty == null) { throw new InvalidOperationException("An attempt was made to add an item (" + this.Name + ") without specifying its data type."); } this.SetDataType(defaultItemProperty.DataType); } } if (string.IsNullOrEmpty(this.Title)) { if (itemIsXceedDataRow) { this.Title = this.Name; } else { if (defaultItemProperty == null) { defaultItemProperty = itemPropertyCollection.FindDefaultItemProperty(this.Name) as DataGridItemProperty; } if (defaultItemProperty == null) { this.Title = this.Name; } else { this.Title = defaultItemProperty.Title; } } } if (!this.IsReadOnly) { if (defaultItemProperty == null) { defaultItemProperty = itemPropertyCollection.FindDefaultItemProperty(this.Name) as DataGridItemProperty; } if (defaultItemProperty != null) { this.SetIsReadOnly(defaultItemProperty.IsReadOnly); } } if (this.OverrideReadOnlyForInsertion == null) { //only try to affect the DataType if the DefaultItemProperties were set. (will not be the case when XAML parsing DetailDescriptions) if (itemPropertyCollection.DefaultItemProperties != null) { if (defaultItemProperty == null) { defaultItemProperty = itemPropertyCollection.FindDefaultItemProperty(this.Name) as DataGridItemProperty; } this.SetOverrideReadOnlyForInsertion((defaultItemProperty != null) && (defaultItemProperty.OverrideReadOnlyForInsertion.HasValue) ? defaultItemProperty.OverrideReadOnlyForInsertion.Value : false); } } if ((!string.IsNullOrEmpty(this.ValueXPath)) && (string.IsNullOrEmpty(this.ValuePath))) { this.SetValuePath("InnerText"); } bool foreignKeyDescriptionIsNull = (this.ForeignKeyDescription == null); bool foreignKeyDescriptionItemsSourceIsNull = false; if (!foreignKeyDescriptionIsNull) { foreignKeyDescriptionItemsSourceIsNull = (this.ForeignKeyDescription.ItemsSource == null); } // Update the ForeignKeyDescription if not set if (foreignKeyDescriptionIsNull || foreignKeyDescriptionItemsSourceIsNull) { if (defaultItemProperty == null) { defaultItemProperty = itemPropertyCollection.FindDefaultItemProperty(this.Name) as DataGridItemProperty; } if ((defaultItemProperty != null) && (defaultItemProperty.ForeignKeyDescription != null)) { if (foreignKeyDescriptionIsNull) { this.SetForeignKeyDescription(defaultItemProperty.ForeignKeyDescription); } else { if (foreignKeyDescriptionItemsSourceIsNull) { this.ForeignKeyDescription.ItemsSource = defaultItemProperty.ForeignKeyDescription.ItemsSource; } } } } }
protected DataGridItemProperty(DataGridItemProperty template) { throw new NotSupportedException(); }
/// <summary> /// Builds collection of item properties. /// </summary> /// <param name="parametersCount">Parameters count.</param> /// <param name="itemPorpertiesCollection">Item properties collection.</param> /// <param name="collectionSource">Collection source.</param> private void _BuildCollectionSource(int parametersCount, ArrayList itemPorpertiesCollection, DataGridCollectionViewSource collectionSource) { Debug.Assert(null != itemPorpertiesCollection); Debug.Assert(null != collectionSource); collectionSource.ItemProperties.Clear(); foreach (DataGridItemProperty property in itemPorpertiesCollection) { if (!property.Name.Equals(DYNAMIC_FIELDS_ALIAS)) collectionSource.ItemProperties.Add(property); else { for (int index = 0; index < parametersCount; ++index) { string valuePath = property.ValuePath + string.Format(DYNAMIC_VALUE_NAME_FORMAT, index); string valueName = _GetDynamicFieldName(index); var newProperty = new DataGridItemProperty(valueName, valuePath, typeof(string)); collectionSource.ItemProperties.Add(newProperty); } } } }
public PropertyDescriptorFromItemProperty(DataGridItemProperty dataGridItemProperty) : base(dataGridItemProperty) { m_propertyDescriptorForValueChanged = dataGridItemProperty.PropertyDescriptor; }
public PropertyDescriptorFromItemProperty( DataGridItemProperty dataGridItemProperty ) : base( dataGridItemProperty ) { m_propertyDescriptorForValueChanged = dataGridItemProperty.PropertyDescriptor; }