public static SetterValueBindingHelper GetPropertyBinding(FrameworkElement element)
 {
     if (null == element)
     {
         throw new ArgumentNullException("element");
     }
     return (SetterValueBindingHelper)element.GetValue(PropertyBindingProperty);
 }
 /// <summary>
 /// Gets the <see cref="T:System.Windows.Interactivity.BehaviorCollection"/> associated with a specified object.
 /// 
 /// </summary>
 /// <param name="obj">The object from which to retrieve the <see cref="T:System.Windows.Interactivity.BehaviorCollection"/>.</param>
 /// <returns>
 /// A <see cref="T:System.Windows.Interactivity.BehaviorCollection"/> containing the behaviors associated with the specified object.
 /// </returns>
 public static BehaviorCollection GetBehaviors(FrameworkElement obj)
 {
     BehaviorCollection behaviorCollection = (BehaviorCollection)obj.GetValue(Interaction.BehaviorsProperty);
     if (behaviorCollection == null)
     {
         behaviorCollection = new BehaviorCollection();
         obj.SetValue(Interaction.BehaviorsProperty, behaviorCollection);
     }
     return behaviorCollection;
 }
        private IList<IMvxUpdateableBinding> GetOrCreateBindingsList(FrameworkElement attachedObject)
        {
            var existing = attachedObject.GetValue(BindingsListProperty) as IList<IMvxUpdateableBinding>;
            if (existing != null)
                return existing;

            // attach the list
            var newList = new List<IMvxUpdateableBinding>();
            attachedObject.SetValue(BindingsListProperty, newList);

            // create a binding watcher for the list
#if WINDOWS_WPF
            var binding = new System.Windows.Data.Binding();
#endif
#if WINDOWS_COMMON
            var binding = new Windows.UI.Xaml.Data.Binding();
#endif
            bool attached = false;
            Action attachAction = () =>
            {
                if (attached)
                    return;
                BindingOperations.SetBinding(attachedObject, DataContextWatcherProperty, binding);
                attached = true;
            };

            Action detachAction = () =>
            {
                if (!attached)
                    return;
#if WINDOWS_COMMON
                attachedObject.ClearValue(DataContextWatcherProperty);
#else
                BindingOperations.ClearBinding(attachedObject, DataContextWatcherProperty);
#endif
                attached = false;
            };
            attachAction();
            attachedObject.Loaded += (o, args) =>
            {
                attachAction();
            };
            attachedObject.Unloaded += (o, args) =>
            {
                detachAction();
            };

            return newList;
        }
 public static ICommand GetLoadedCommand(FrameworkElement frameworkElement)
 {
     return (ICommand)frameworkElement.GetValue(LoadedCommandProperty);
 }
        private static Storyboard CreateStoryboard(
            FrameworkElement target,
            DependencyProperty animatingDependencyProperty,
            string propertyPath,
            ref object toValue,
            TimeSpan durationTimeSpan,
            EasingFunctionBase easingFunction)
        {
            object fromValue = target.GetValue(animatingDependencyProperty);

            double fromDoubleValue;
            double toDoubleValue;

            DateTime fromDateTime;
            DateTime toDateTime;

            Storyboard storyBoard = new Storyboard();
            Storyboard.SetTarget(storyBoard, target);
          
            Storyboard.SetTargetProperty(storyBoard, propertyPath);

            if ((fromValue != null && toValue != null))
            {
                if (ValueHelper.TryConvert(fromValue, out fromDoubleValue) && ValueHelper.TryConvert(toValue, out toDoubleValue))
                {
                    DoubleAnimation doubleAnimation = new DoubleAnimation();
                    doubleAnimation.EnableDependentAnimation = true;
#if !NO_EASING_FUNCTIONS
                    doubleAnimation.EasingFunction = easingFunction;
#endif
                    doubleAnimation.Duration = durationTimeSpan;
                    doubleAnimation.To = ValueHelper.ToDouble(toValue);
                    toValue = doubleAnimation.To;

                    storyBoard.Children.Add(doubleAnimation);
                }
                else if (ValueHelper.TryConvert(fromValue, out fromDateTime) && ValueHelper.TryConvert(toValue, out toDateTime))
                {
                    ObjectAnimationUsingKeyFrames keyFrameAnimation = new ObjectAnimationUsingKeyFrames();
                    keyFrameAnimation.EnableDependentAnimation = true;
                    keyFrameAnimation.Duration = durationTimeSpan;

                    long intervals = (long)(durationTimeSpan.TotalSeconds * KeyFramesPerSecond);
                    if (intervals < 2L)
                    {
                        intervals = 2L;
                    }

                    IEnumerable<TimeSpan> timeSpanIntervals =
                        ValueHelper.GetTimeSpanIntervalsInclusive(durationTimeSpan, intervals);

                    IEnumerable<DateTime> dateTimeIntervals =
                        ValueHelper.GetDateTimesBetweenInclusive(fromDateTime, toDateTime, intervals);

                    IEnumerable<DiscreteObjectKeyFrame> keyFrames =
                        EnumerableFunctions.Zip(
                            dateTimeIntervals,
                            timeSpanIntervals,
                            (dateTime, timeSpan) => new DiscreteObjectKeyFrame() { Value = dateTime, KeyTime = timeSpan });

                    foreach (DiscreteObjectKeyFrame keyFrame in keyFrames)
                    {
                        keyFrameAnimation.KeyFrames.Add(keyFrame);
                        toValue = keyFrame.Value;
                    }

                    storyBoard.Children.Add(keyFrameAnimation);
                }
            }

            if (storyBoard.Children.Count == 0)
            {
                ObjectAnimationUsingKeyFrames keyFrameAnimation = new ObjectAnimationUsingKeyFrames();
                keyFrameAnimation.EnableDependentAnimation = true;
                DiscreteObjectKeyFrame endFrame = new DiscreteObjectKeyFrame() { Value = toValue, KeyTime = new TimeSpan(0, 0, 0) };
                keyFrameAnimation.KeyFrames.Add(endFrame);

                storyBoard.Children.Add(keyFrameAnimation);
            }

           return storyBoard;
        }
 public static FullWindowPopup GetAttachedPopup(FrameworkElement obj)
 {
     return (FullWindowPopup)obj.GetValue(AttachedPopupProperty);
 }
Exemple #7
0
 /// <summary>
 /// Gets value describing whether FrameworkElement is acting as View in MVVM.
 /// </summary>
 public static bool GetRegisterAsMediaService(FrameworkElement target)
 {
     return (bool)target.GetValue(RegisterAsMediaServiceProperty);
 }
Exemple #8
0
 public static Thickness GetMargin(FrameworkElement target) {
     return (Thickness)target.GetValue(MarginProperty);
 }
Exemple #9
0
 public static object GetContent(FrameworkElement d) {
     return d.GetValue(ContentProperty);
 }
Exemple #10
0
 public static bool GetEventArgsAsParameter(FrameworkElement target) {
     return (bool)target.GetValue(EventArgsAsParameterProperty);
 }
Exemple #11
0
 public static IList <VisualStateGroup> GetVisualStateGroups(FrameworkElement obj)
 => (IList <VisualStateGroup>)obj.GetValue(VisualStateGroupsProperty);
Exemple #12
0
 public static object GetCommandParameter(FrameworkElement target) {
     return (object)target.GetValue(CommandParameterProperty);
 }
Exemple #13
0
 public static ICommand GetCommand(FrameworkElement target) {
     return (ICommand)target.GetValue(CommandProperty);
 }
Exemple #14
0
 public static string GetEvent(FrameworkElement target) {
     return (string)target.GetValue(EventProperty);
 }
 public static bool GetObserve(FrameworkElement frameworkElement)
 {
     return (bool)frameworkElement.GetValue(ObserveProperty);
 }
        /// <summary>
        /// Copy the layout properties from the source element to the target element, clearing them from the source.
        /// </summary>
        /// <param name="source">The source of the layout properties</param>
        /// <param name="target">The destination of the layout properties</param>
        private static void CopyLayoutProperties(FrameworkElement source, FrameworkElement target, bool restoring)
        {
            WrapperCanvas canvas = (restoring ? ((WrapperCanvas)source) : ((WrapperCanvas)target)) as WrapperCanvas;
            if (canvas.LocalValueCache == null)
                canvas.LocalValueCache = new Dictionary<DependencyProperty, object>();

            foreach (DependencyProperty property in LayoutProperties)
            {
                if (!ChildAffectingLayoutProperties.Contains(property))
                {
                    object actualValue = CacheActualValueHelper(source, property);
                    object localValue = CacheLocalValueHelper(source, property);
                    if (actualValue != localValue)
                        return;

                    if (restoring)
                    {
                        ReplaceCachedLocalValueHelper(target, property, canvas.LocalValueCache[property]);
                    }
                    else
                    {
                        object targetValue = target.GetValue(property);
                        canvas.LocalValueCache[property] = localValue;
                        if (IsVisibilityProperty(property))
                        {
                            canvas.DestinationVisibilityCache = (Visibility)source.GetValue(property);
                        }
                        else
                        {
                            target.SetValue(property, source.GetValue(property));
                        }
                        source.SetValue(property, targetValue);
                    }
                }
            }
        }
 public static double GetObservedHeight(FrameworkElement frameworkElement)
 {
  
     return (double)frameworkElement.GetValue(ObservedHeightProperty);
 }
 public static float GetHtml(FrameworkElement target) {
     return (float)target.GetValue(HtmlProperty);
 }