GetPropertyRoute() public static méthode

public static GetPropertyRoute ( DependencyObject obj ) : PropertyRoute
obj System.Windows.DependencyObject
Résultat PropertyRoute
Exemple #1
0
        void ChangeDataContext_Handler(object sender, ChangeDataContextEventArgs e)
        {
            if (e.Refresh)
            {
                var l = ((Entity)this.DataContext).ToLite().Retrieve();
                this.DataContext = null;
                this.DataContext = l;
                e.Handled        = true;
            }
            else
            {
                if (e.NewDataContext == null)
                {
                    throw new ArgumentNullException("NewDataContext");
                }

                Type type       = Common.GetPropertyRoute(MainControl).Type;
                Type entityType = e.NewDataContext.GetType();
                if (type != null && !type.IsAssignableFrom(entityType))
                {
                    throw new InvalidCastException("The DataContext is a {0} but TypeContext is {1}".FormatWith(entityType.Name, type.Name));
                }

                DataContext = null;
                DataContext = e.NewDataContext;
                e.Handled   = true;
            }
        }
Exemple #2
0
        public override object ProvideValue(IServiceProvider serviceProvider)
        {
            if (string.IsNullOrEmpty(Continuation))
            {
                throw new Exception("continuation is null");
            }

            IProvideValueTarget provider = (IProvideValueTarget)serviceProvider.GetService(typeof(IProvideValueTarget));

            if (!(provider.TargetObject is DependencyObject))
            {
                return(this);
            }

            var depObj = (DependencyObject)provider.TargetObject;

            PropertyRoute route = Common.GetPropertyRoute(depObj);

            if (route == null)
            {
                throw new FormatException("ContinueRoute is only available with a previous TypeContext");
            }

            return(Continue(route, Continuation));
        }
        protected override string GetNameCore()
        {
            var parentRoute = Common.GetPropertyRoute(Owner);

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

            return(parentRoute.Add("Item").ToString());
        }
        private void RecalculateVisibility(object oldValue, object newValue)
        {
            if (AutoChild)
            {
                // when datacontext change is fired but its not loaded, it's quite possible that some Common.Routes are not working yet
                if (newValue == null /* || !IsLoaded*/)
                {
                    Child = null;
                }
                else
                {
                    EntitySettings es = Navigator.Manager.EntitySettings.TryGetC(newValue.GetType());
                    if (es == null)
                    {
                        Child = new TextBox
                        {
                            Text       = "No EntitySettings for {0}".FormatWith(newValue.GetType()),
                            Foreground = Brushes.Red,
                            FontWeight = FontWeights.Bold
                        }
                    }
                    ;
                    else
                    {
                        Child = es.CreateView((ModifiableEntity)newValue, Common.GetPropertyRoute(this));
                    }
                }
            }
            if (Child != null)
            {
                if (newValue == null)
                {
                    Child.Visibility = Visibility.Hidden;
                }
                else
                {
                    Child.Visibility = Visibility.Visible;
                }

                if (oldValue != null && newValue != null)
                {
                    Child.BeginAnimation(UIElement.OpacityProperty, animation);
                }
            }
        }
        void AutoControl_Initialized(object sender, EventArgs e)
        {
            PropertyRoute typeContext = Common.GetPropertyRoute(this);

            if (typeContext == null || typeContext.Type == null)
            {
                Content = new Label {
                    Foreground = Brushes.Red, Content = "No TypeContext"
                };
                return;
            }

            Type type = typeContext.Type;


            XElement element = GenerateEntityStackPanel(type);

            this.Content = XamlReader.Load(element.CreateReader());
        }
Exemple #6
0
 public virtual PropertyRoute GetEntityPropertyRoute()
 {
     return(Common.GetPropertyRoute(this));
 }