/// <summary>
        /// Returns the data context of the specified <paramref name="obj"/>.
        /// </summary>
        /// <param name="obj">The target object to search the data context.</param>
        /// <param name="dataContext">The data context on object <paramref name="obj"/> or
        /// <c>null</c>, if no data context is present on the object.</param>
        /// <returns><c>true</c>, if a data context was found. In this case, the returned
        /// <paramref name="dataContext"/> is not-null. <c>false</c> else.</returns>
        /// <remarks>
        /// This method attaches change handlers to all relevant properties on the searched path.
        /// </remarks>
        protected bool GetDataContext(object obj, out BindingMarkupExtension dataContext)
        {
            DependencyObject current = obj as DependencyObject;

            if (current == null)
            {
                dataContext = null;
                return(false);
            }
            AbstractProperty dataContextProperty = current.DataContextProperty;

            AttachToSourcePathProperty(dataContextProperty);
            dataContext = dataContextProperty.GetValue() as BindingMarkupExtension;
            return(dataContext != null);
        }
        public override void DeepCopy(IDeepCopyable source, ICopyManager copyManager)
        {
            Detach();
            base.DeepCopy(source, copyManager);
            BindingMarkupExtension bme = (BindingMarkupExtension)source;

            Source         = copyManager.GetCopy(bme.Source);
            ElementName    = bme.ElementName;
            RelativeSource = bme.RelativeSource;
            CheckTypeOfSource();
            Path = bme.Path;
            Mode = bme.Mode;
            UpdateSourceTrigger = bme.UpdateSourceTrigger;
            Converter           = copyManager.GetCopy(bme.Converter);
            ConverterParameter  = copyManager.GetCopy(bme.ConverterParameter);

            _compiledPath = bme._compiledPath;
            Attach();
        }
Exemple #3
0
 protected CommandBaseMarkupExtension()
 {
     _source = new BindingMarkupExtension(this);
 }
 /// <summary>
 /// Returns the data context of the specified <paramref name="obj"/>.
 /// </summary>
 /// <param name="obj">The target object to search the data context.</param>
 /// <param name="dataContext">The data context on object <paramref name="obj"/> or
 /// <c>null</c>, if no data context is present on the object.</param>
 /// <returns><c>true</c>, if a data context was found. In this case, the returned
 /// <paramref name="dataContext"/> is not-null. <c>false</c> else.</returns>
 /// <remarks>
 /// This method attaches change handlers to all relevant properties on the searched path.
 /// </remarks>
 protected bool GetDataContext(object obj, out BindingMarkupExtension dataContext)
 {
   DependencyObject current = obj as DependencyObject;
   if (current == null)
   {
     dataContext = null;
     return false;
   }
   AbstractProperty dataContextProperty = current.DataContextProperty;
   AttachToSourcePathProperty(dataContextProperty);
   dataContext = dataContextProperty.GetValue() as BindingMarkupExtension;
   return dataContext != null;
 }
 protected CommandBaseMarkupExtension()
 {
   _source = new BindingMarkupExtension(this);
 }