예제 #1
0
        private object FindOrBindKeyValue(FrameworkElement element, DependencyProperty property)
        {
            foreach (FrameworkElement ancestor in VisualTree.EnumerateAncestors(element, true))
            {
                ModelDefinitionContainer container = UserModelPresenter.GetContainer(ancestor);
                if (container != null)
                {
                    if (container.Definition != null && Key != null)
                    {
                        return(container.Definition.Metadata.Get(Key, default(object)));
                    }

                    container.Changed += () =>
                    {
                        if (Key != null)
                        {
                            object value = container.Definition.Metadata.Get(Key, default(object));
                            element.SetValue(property, value);
                        }
                    };
                    break;
                }
            }

            return(null);
        }
예제 #2
0
 private static void BindModelContainerChanged(DependencyObject d)
 {
     foreach (FrameworkElement ancestor in VisualTree.EnumerateAncestors((FrameworkElement)d))
     {
         ModelDefinitionContainer container = UserModelPresenter.GetContainer(ancestor);
         if (container != null)
         {
             SetContainerDefinition(d, container.Definition);
             container.Changed += () => SetContainerDefinition(d, container.Definition);
             break;
         }
     }
 }
예제 #3
0
 public static void SetContainer(DependencyObject obj, ModelDefinitionContainer value)
 {
     obj.SetValue(ContainerProperty, value);
 }