GetValue() public method

public GetValue ( DependencyProperty dp ) : object
dp DependencyProperty
return object
Example #1
1
        /// <summary>
        /// Gets the value of the <strong>AttachedDataContext</strong> attached property from a given 
        /// <see cref="DependencyObject"/> object.
        /// </summary>
        /// <param name="obj">The object from which to read the property value.</param>
        /// <return>The value of the <strong>AttachedDataContext</strong> attached property.</return>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="obj"/> is <see langword="null"/>.
        /// </exception>
        public static object GetAttachedDataContext(DependencyObject obj)
        {
            if (obj == null)
            throw new ArgumentNullException("obj");

              return obj.GetValue(AttachedDataContextProperty);
        }
        public static bool SetPropertyValueOnTarget(DependencyObject target, string propertyName,bool ballowed)
        {
            var prop = GetDependencyProperty(target, propertyName);

            if (target.GetValue(prop) == null || target.GetValue(prop).GetType() == typeof(string))
            {
                if (!ballowed)
                {
                    target.SetValue(prop, String.Empty);
                }
                return true;
            }

            if (target.GetValue(prop).GetType() == typeof(bool))
            {
                target.SetValue(prop, ballowed);
                return true;
            }

            if (target.GetValue(prop).GetType() == typeof(Visibility))
            {
                if (ballowed)
                {
                    target.SetValue(prop, Visibility.Visible);
                }
                else
                {
                    target.SetValue(prop, Visibility.Collapsed);
                }
                return true;
            }

            return false;
        }
Example #3
0
 public static PushBindingCollection GetPushBindings(DependencyObject obj)
 {
     if (obj.GetValue(PushBindingsProperty) == null)
     {
         obj.SetValue(PushBindingsProperty, new PushBindingCollection(obj));
     }
     return (PushBindingCollection)obj.GetValue(PushBindingsProperty);
 }
 // ------------------------------------------------------------------
 // Constructor.
 // Remarks - the pageWidth parameter can be used to limit column
 // properties if the element is a FlowDocument.
 // ------------------------------------------------------------------
 internal ColumnPropertiesGroup(DependencyObject o)
 {
     _columnWidth = (double)o.GetValue(FlowDocument.ColumnWidthProperty);
     _columnGap = (double)o.GetValue(FlowDocument.ColumnGapProperty);
     _columnRuleWidth = (double)o.GetValue(FlowDocument.ColumnRuleWidthProperty);
     _columnRuleBrush = (Brush)o.GetValue(FlowDocument.ColumnRuleBrushProperty);
     _isColumnWidthFlexible = (bool)o.GetValue(FlowDocument.IsColumnWidthFlexibleProperty);
 }
Example #5
0
	private static void OnPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
	{
		var sourceValue = d.GetValue(ExtendedBinding.SourceProperty);
		var targetValue = d.GetValue(ExtendedBinding.TargetProperty);
		if (e.Property == ExtendedBinding.SourceProperty && !object.ReferenceEquals(sourceValue, targetValue))
			d.SetValue(ExtendedBinding.TargetProperty, sourceValue);
		else if (e.Property == ExtendedBinding.TargetProperty && !object.ReferenceEquals(sourceValue, targetValue))
			d.SetValue(ExtendedBinding.SourceProperty, targetValue);
	}
        internal static Typeface GetModifiedTypeface(DependencyObject element, FontFamily fontFamily)
        {
            Debug.Assert(element != null); 

            FontStyle   fontStyle   = (FontStyle)   element.GetValue(TextElement.FontStyleProperty); 
            FontWeight  fontWeight  = (FontWeight)  element.GetValue(TextElement.FontWeightProperty); 
            FontStretch fontStretch = (FontStretch) element.GetValue(TextElement.FontStretchProperty);
 
            return new Typeface(fontFamily, fontStyle, fontWeight, fontStretch);
        }
 internal static List<ConnectionPoint> GetConnectionPoints(DependencyObject obj)
 {
     if (obj is StartSymbol)
     {
         return (List<ConnectionPoint>)obj.GetValue(StateContainerEditor.ConnectionPointsProperty);
     }
     if (!(obj is VirtualizedContainerService.VirtualizingContainer))
     {
         obj = VisualTreeUtils.FindVisualAncestor<VirtualizedContainerService.VirtualizingContainer>(obj);
     }
     return (List<ConnectionPoint>)obj.GetValue(StateContainerEditor.ConnectionPointsProperty);
 }
 private static void OnTimeChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
 {
     DoubleAnimation animation = (DoubleAnimation)sender;
     double time = GetTime(animation);
     Thickness from = (Thickness)sender.GetValue(FromProperty);
     Thickness to = (Thickness)sender.GetValue(ToProperty);
     DependencyProperty targetProperty = (DependencyProperty)sender.GetValue(TargetPropertyProperty);
     DependencyObject target = (DependencyObject)sender.GetValue(TargetProperty);
     target.SetValue(targetProperty, new Thickness((to.Left - from.Left) * time + from.Left,
                                                   (to.Top - from.Top) * time + from.Top,
                                                   (to.Right - from.Right) * time + from.Right,
                                                   (to.Bottom - from.Bottom) * time + from.Bottom));
 }
        public static AnimationClock AnimateEasingEquation(
            DependencyObject element,
            DependencyProperty prop,
            EasingFunction function,            
            double to,
            int durationMS)
        {
            double from = double.IsNaN((double)element.GetValue(prop)) ?
                                0 :
                                (double)element.GetValue(prop);

            AnimationTimeline timeline = GetEasingAnimation(function, EasingMode.EaseIn, from, to, durationMS);
            return Animate(element, prop, timeline, durationMS, null, null, null);
        }
Example #10
0
        public static string GetBoundPassword(DependencyObject d)
        {
            var box = d as PasswordBox;
            if (box == null)
                return (string) d.GetValue(BoundPasswordProperty);

            box.PasswordChanged -= PasswordChanged;
            box.PasswordChanged += PasswordChanged;

            var password = box.ToString();
            if (password != null)
                SetSelection(box, password.Length, 0);

            return (string)d.GetValue(BoundPasswordProperty);
        }
        public static SortInfo GetSortInfo(DependencyObject obj)
        {
            if (obj == null)
                throw new ArgumentNullException("obj");

            return (SortInfo)obj.GetValue(SortInfoProperty.DependencyProperty);
        }
        public static string GetSortField(DependencyObject obj)
        {
            if (obj == null)
                throw new ArgumentNullException("obj");

            return (string)obj.GetValue(SortFieldProperty);
        }
        public static bool GetHeaderSort(DependencyObject obj)
        {
            if (obj == null)
                throw new ArgumentNullException("obj");

            return (bool)obj.GetValue(HeaderSortProperty);
        }
Example #14
0
        /// <summary>
        /// Gets the IList that contains the values that should be selected.
        /// </summary>
        /// <param name="element">The ListBox to check.</param>
        public static IList GetSelectedItemsSource(DependencyObject element)
        {
            if (element == null)
                throw new ArgumentNullException("element");

            return (IList)element.GetValue(SelectedItemsSourceProperty);
        }
Example #15
0
        /// <summary>
        /// Gets the update source on change.
        /// </summary>
        /// <param name="obj">The object.</param>
        /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
        /// <exception cref="System.ArgumentNullException">obj</exception>
        public static bool GetUpdateSourceOnChange
          (DependencyObject obj)
        {
            if (obj == null) throw new ArgumentNullException("obj");

            return (bool)obj.GetValue(UpdateSourceOnChangeProperty);
        }
Example #16
0
        /// <summary>
        /// Gets the value of the <see cref="P:DigitalRune.Window.AccessKeyScope.IsEnabled"/>
        /// attached property from a given <see cref="DependencyObject"/> object.
        /// </summary>
        /// <param name="obj">The object from which to read the property value.</param>
        /// <returns>
        /// The value of the <see cref="P:DigitalRune.Window.AccessKeyScope.IsEnabled"/>
        /// attached property.
        /// </returns>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="obj"/> is <see langword="null"/>.
        /// </exception>
        public static bool GetIsEnabled(DependencyObject obj)
        {
            if (obj == null)
                throw new ArgumentNullException(nameof(obj));

            return (bool)obj.GetValue(IsEnabledProperty);
        }
Example #17
0
	//
	// Attached Property Accessor Methods
	//
	public static bool GetIsVirtualizing (DependencyObject o)
	{
		if (o == null)
			throw new ArgumentNullException ("o");
		
		return (bool) o.GetValue (VirtualizingStackPanel.IsVirtualizingProperty);
	}
Example #18
0
        /// <summary>
        /// Gets the state of the current sub.
        /// </summary>
        /// <param name="obj">The object.</param>
        /// <returns>System.String.</returns>
        public static string GetCurrentSubState(DependencyObject obj)
        {
            if (obj != null)
                return (string)obj.GetValue(CurrentSubStateProperty);

            return null;
        }
Example #19
0
        public static bool GetLoadBindingsFromVM(DependencyObject obj)
        {
            if (obj == null)
                throw new ArgumentNullException("obj");

            return (bool)obj.GetValue(LoadBindingsFromVMProperty);
        }
        /// <summary>
        /// Gets the value of the <see cref="ErrorMessageProperty"/> property.
        /// </summary>
        /// <param name="dependencyObject">
        /// The dependency object.
        /// </param>
        /// <returns>
        /// The property value.
        /// </returns>
        /// <exception cref="ArgumentNullException">
        /// The <paramref name="dependencyObject"/> parameter is null.
        /// </exception>
        public static string GetErrorMessage(DependencyObject dependencyObject)
        {
            if (dependencyObject == null)
                throw new ArgumentNullException("dependencyObject");

            return (string)dependencyObject.GetValue(ErrorMessageProperty);
        }
        public static bool GetGenerateColumns(DependencyObject element) {
            if (element == null) {
                throw new ArgumentNullException("element");
            }

            return (bool)element.GetValue(GenerateColumnsProperty);
        }
Example #22
0
        /// <summary>
        /// Gets the value for the <see cref="RegionNameProperty"/> attached property.
        /// </summary>
        /// <param name="regionTarget">The object to adapt. This is typically a container (i.e a control).</param>
        /// <returns>The name of the region that should be created when
        /// <see cref="RegionManagerProperty"/> is also set in this element.</returns>
        public static string GetRegionName(DependencyObject regionTarget)
        {
            if (regionTarget == null)
                throw new ArgumentNullException(nameof(regionTarget));

            return regionTarget.GetValue(RegionNameProperty) as string;
        }
 public static double GetWeight(DependencyObject uiElement)
 {
   if (uiElement == null)
     return 0;
   else
     return (double)uiElement.GetValue(TreeMapsPanel.WeightProperty);
 }
Example #24
0
 public static Object Eval(Object container, String expression)
 {
     Binding binding = new Binding(expression) { Source = container };
        DependencyObject dummyDO = new DependencyObject();
        BindingOperations.SetBinding(dummyDO, DummyProperty, binding);
        return dummyDO.GetValue(DummyProperty);
 }
Example #25
0
	public static VirtualizationMode GetVirtualizationMode (DependencyObject element)
	{
		if (element == null)
			throw new ArgumentNullException ("element");
		
		return (VirtualizationMode) element.GetValue (VirtualizingStackPanel.VirtualizationModeProperty);
	}
Example #26
0
        public static ColumnCollection GetColumnsCollection(DependencyObject d)
        {
            if (d != null)
                return (ColumnCollection)d.GetValue(ColumnsCollectionProperty);

            return null;
        }
 public static bool GetIsBaseMap(DependencyObject layer)
 {
     if (layer != null)
         return (bool)layer.GetValue(ESRI.ArcGIS.Client.WebMap.Document.IsBaseMapProperty);
     
     return default(bool);
 }
Example #28
0
 private static void OnAttachChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
 {
     Action<System.Windows.Interactivity.TriggerBase> action = null;
     System.Windows.Interactivity.TriggerCollection allTriggers;
     if (e.NewValue != e.OldValue)
     {
         System.Windows.Interactivity.TriggerBase[] enumerable = (System.Windows.Interactivity.TriggerBase[]) d.GetValue(MessageTriggersProperty);
         allTriggers = Interaction.GetTriggers(d);
         if (enumerable != null)
         {
             if (action == null)
             {
                 action = (Action<System.Windows.Interactivity.TriggerBase>) (x => allTriggers.Remove(x));
             }
             enumerable.Apply<System.Windows.Interactivity.TriggerBase>(action);
         }
         System.Windows.Interactivity.TriggerBase[] baseArray2 = Parser.Parse(d, e.NewValue as string).ToArray<System.Windows.Interactivity.TriggerBase>();
         baseArray2.Apply<System.Windows.Interactivity.TriggerBase>(new Action<System.Windows.Interactivity.TriggerBase>(allTriggers.Add));
         if (baseArray2.Length > 0)
         {
             d.SetValue(MessageTriggersProperty, baseArray2);
         }
         else
         {
             d.ClearValue(MessageTriggersProperty);
         }
     }
 }
Example #29
0
        /// <summary>
        /// Gets the value of the <strong>MultiBindings</strong> attached property from a given 
        /// <see cref="DependencyObject"/> object.
        /// </summary>
        /// <param name="obj">The object from which to read the property value.</param>
        /// <return>The value of the <strong>MultiBindings</strong> attached property.</return>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="obj"/> is <see langword="null"/>.
        /// </exception>
        public static MultiBindings GetMultiBindings(DependencyObject obj)
        {
            if (obj == null)
            throw new ArgumentNullException("obj");

              return (MultiBindings)obj.GetValue(MultiBindingsProperty);
        }
Example #30
0
        /// <summary>
        /// Used to retrieve the root, non-framework-created view.
        /// </summary>
        /// <param name="view">The view to search.</param>
        /// <returns>The root element that was not created by the framework.</returns>
        /// <remarks>In certain instances the WindowManager creates UI elements in order to display windows.
        /// For example, if you ask the window manager to show a UserControl as a dialog, it creates a window to host the UserControl in.
        /// The WindowManager marks that element as a framework-created element so that it can determine what it created vs. what was intended by the developer.
        /// Calling GetSignificantView allows the framework to discover what the original element was. 
        /// </remarks>
        public static DependencyObject GetSignificantView(DependencyObject view)
        {
            if((bool)view.GetValue(IsElementGeneratedProperty))
                return (DependencyObject)((ContentControl)view).Content;

            return view;
        }