Inheritance: System.Windows.RoutedEventArgs
Ejemplo n.º 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;
            }
        }
        void ChangeEntity(object sender, ChangeDataContextEventArgs e)
        {
            if (e.Refresh)
            {
                var lite = (Entity as IEntity)?.ToLite();

                if (lite != null)
                {
                    this.Entity = null;
                    this.Entity = lite.Retrieve();
                }
            }
            else
            {
                this.Entity = null;
                this.Entity = e.NewDataContext;
            }

            e.Handled = true;
        }
Ejemplo n.º 3
0
        void ChangeEntity(object sender, ChangeDataContextEventArgs e)
        {
            if (e.Refresh)
            {
                var lite = (Entity as IIdentifiable).ToLite();

                if (lite != null)
                {
                    this.Entity = null;
                    this.Entity = lite.Retrieve();
                }
            }
            else
            {
                this.Entity = null;
                this.Entity = e.NewDataContext;
            }
          
            e.Handled = true;
        }
Ejemplo n.º 4
0
        void ChangeDataContext_Handler(object sender, ChangeDataContextEventArgs e)
        {
            if (e.Refresh)
            {
                var l = ((IdentifiableEntity)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}".Formato(entityType.Name, type.Name));

                DataContext = null;
                DataContext = e.NewDataContext;
                e.Handled = true;
            }
        }