partial void UpdateLayer(Layer instance);
 partial void DeleteLayer(Layer instance);
 partial void InsertLayer(Layer instance);
		private void detach_Layers(Layer entity)
		{
			this.SendPropertyChanging();
			entity.Material = null;
		}
		private void attach_Layers(Layer entity)
		{
			this.SendPropertyChanging();
			entity.Material = this;
		}
        /// <summary>
        /// Function that calculates the atomic density of an <see cref="LayerElement"/> inside a <see cref="Layer"/>.
        /// </summary>
        /// <param name="layer">The <see cref="Layer"/> containing the <see cref="LayerElement"/>.</param>
        /// <param name="layerElement">The <see cref="LayerElement"/> which atomic density is calulated.</param>
        /// <returns></returns>
        private double CalculateAtomicDensity(Layer layer, LayerElement layerElement)
        {
            double MassOfMolecule = 0;
            foreach (LayerElement l in layer.LayerElements)
                MassOfMolecule += l.Isotope.Mass * l.StoichiometricFactor;

            double NumberOfMolecules = layer.Density / MassOfMolecule / 1.66053904E-24;

            double NumberOfAtomsInMolecule = layer.LayerElements.Select(x => x.StoichiometricFactor).ToList().Sum();

            double AtomicDensityOfElement = NumberOfMolecules * layerElement.StoichiometricFactor;
            Console.WriteLine("Atomic density of " + layerElement.Isotope.Element.LongName+ ": " + AtomicDensityOfElement);
            return AtomicDensityOfElement;
        }
        /// <summary>
        /// Function that adds a new <see cref="Layer"/> to the selected <see cref="Material"/>.
        /// </summary>
        public void _AddLayerCommand()
        {
            if (SelectedMaterial == null) return;

            Layer newLayer = new Layer { LayerIndex = Layers.Count(), MaterialID = SelectedMaterial.MaterialID, Density = 1 };

            Layers.Add(newLayer);

            SelectedMaterial.Layers.Add(newLayer);
        }