private void RelationalPropertiesDataGrid_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (SelectedProperty == null)
            {
                return;
            }

            RelatedEntityDmsTypes.Clear();
            SelectedDmsType = null;
            PropertiesInRelated.Children.Clear();
            RelatedValues.Document.Blocks.Clear();

            List <DMSType> dmsTypes = new List <DMSType>();

            if (RelationalPropertiesHelper.Relations.ContainsKey(SelectedProperty.Property))
            {
                ModelCode relatedEntity = RelationalPropertiesHelper.Relations[SelectedProperty.Property];
                dmsTypes.AddRange(ModelResourcesDesc.GetLeavesForCoreEntities(relatedEntity));

                if (dmsTypes.Count == 0)
                {
                    dmsTypes.Add(ModelCodeHelper.GetTypeFromModelCode(relatedEntity));
                }
            }

            foreach (DMSType type in dmsTypes)
            {
                RelatedEntityDmsTypes.Add(new DmsTypeViewModel()
                {
                    DmsType = type
                });
            }

            HashSet <ModelCode> referencedTypeProperties = new HashSet <ModelCode>();

            if (RelatedEntityDmsTypes.Count > 0)
            {
                foreach (DmsTypeViewModel referencedDmsType in RelatedEntityDmsTypes)
                {
                    foreach (ModelCode propInReferencedType in modelResourcesDesc.GetAllPropertyIds(referencedDmsType.DmsType))
                    {
                        if (!referencedTypeProperties.Contains(propInReferencedType))
                        {
                            referencedTypeProperties.Add(propInReferencedType);
                        }
                    }
                }
            }

            Label label = new Label()
            {
                FontWeight = FontWeights.UltraBold,
                Content    = "Properties (for classes in selected relation)",
            };

            PropertiesInRelated.Children.Add(label);

            propertiesDesc.Clear();

            if (referencedTypeProperties.Count > 0)
            {
                foreach (ModelCode property in referencedTypeProperties)
                {
                    if (propertiesDesc.ContainsKey(property))
                    {
                        continue;
                    }

                    propertiesDesc.Add(property, property.ToString());

                    CheckBox checkBox = new CheckBox()
                    {
                        Content = property.ToString(),
                    };
                    checkBox.Unchecked += CheckBox_Unchecked;
                    PropertiesInRelated.Children.Add(checkBox);
                }
                CheckAllBtn.IsEnabled = true;
            }
        }